From 01ebb65c30aca31850c83507be8aff244df7ae88 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 19:52:22 -0700 Subject: [PATCH 01/15] Travis: Upgrade to CMake 3.6.3 --- .travis-deps.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis-deps.sh b/.travis-deps.sh index 1404fe19f..451886984 100755 --- a/.travis-deps.sh +++ b/.travis-deps.sh @@ -11,7 +11,7 @@ if [ "$TRAVIS_OS_NAME" = "linux" -o -z "$TRAVIS_OS_NAME" ]; then if [ ! -e $HOME/.local/bin/cmake ]; then echo "CMake not found in the cache, get and extract it..." - curl -L http://www.cmake.org/files/v3.2/cmake-3.2.0-Linux-i386.tar.gz \ + curl -L http://www.cmake.org/files/v3.6/cmake-3.6.3-Linux-x86_64.tar.gz \ | tar -xz -C $HOME/.local --strip-components=1 else echo "Using cached CMake" From 4660bc1c786b5f9d3fed74b6b51a8ba3e468d7e4 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 19:05:50 -0700 Subject: [PATCH 02/15] CMake: Use IMPORTED target for libpng --- CMakeLists.txt | 8 +++----- src/video_core/CMakeLists.txt | 5 ++--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 121b0f2f8..100fd9a62 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -# CMake 3.2 required for cmake to know the right flags for CXX standard on OSX -cmake_minimum_required(VERSION 3.2) +# CMake 3.5 required for support for IMPORTED find_package libraries +cmake_minimum_required(VERSION 3.5) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) function(download_bundled_external remote_path lib_name prefix_var) @@ -131,9 +131,7 @@ set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:_DEBUG> $<$>:NDEBUG>) find_package(PNG QUIET) -if (PNG_FOUND) - add_definitions(-DHAVE_PNG) -else() +if (NOT PNG_FOUND) message(STATUS "libpng not found. Some debugging features have been disabled.") endif() diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index e455f03bd..45f4ad2d5 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -87,7 +87,6 @@ if (ARCHITECTURE_x86_64) endif() if (PNG_FOUND) - target_link_libraries(video_core PRIVATE ${PNG_LIBRARIES}) - target_include_directories(video_core PRIVATE ${PNG_INCLUDE_DIRS}) - target_compile_definitions(video_core PRIVATE ${PNG_DEFINITIONS}) + target_link_libraries(video_core PRIVATE PNG::PNG) + target_compile_definitions(video_core PRIVATE HAVE_PNG) endif() From 0f563111a2048228f10f5a565f57fc10bffd11e3 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 19:21:06 -0700 Subject: [PATCH 03/15] CMake: Use IMPORTED target for Boost --- CMakeLists.txt | 14 ++++++++------ src/citra_qt/CMakeLists.txt | 2 +- src/common/CMakeLists.txt | 1 + src/core/CMakeLists.txt | 2 +- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 100fd9a62..9deb590b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ -# CMake 3.5 required for support for IMPORTED find_package libraries -cmake_minimum_required(VERSION 3.5) +# CMake 3.6 required for FindBoost to define IMPORTED libs properly on unknown Boost versions +cmake_minimum_required(VERSION 3.6) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) function(download_bundled_external remote_path lib_name prefix_var) @@ -135,12 +135,14 @@ if (NOT PNG_FOUND) message(STATUS "libpng not found. Some debugging features have been disabled.") endif() -find_package(Boost 1.57.0 QUIET) +find_package(Boost 1.63.0 QUIET) if (NOT Boost_FOUND) - message(STATUS "Boost 1.57.0 or newer not found, falling back to externals") - set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/boost") + message(STATUS "Boost 1.63.0 or newer not found, falling back to externals") + + set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/externals/boost") + set(Boost_NO_SYSTEM_PATHS OFF) + find_package(Boost QUIET REQUIRED) endif() -include_directories(${Boost_INCLUDE_DIR}) # Include bundled CMake modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules") diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 809e0b938..e2b77a34f 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -92,7 +92,7 @@ else() add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) endif() target_link_libraries(citra-qt PRIVATE audio_core common core input_common video_core) -target_link_libraries(citra-qt PRIVATE ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS} glad) +target_link_libraries(citra-qt PRIVATE ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS} Boost::boost glad) target_link_libraries(citra-qt PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) if(UNIX AND NOT APPLE) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index a33a8cdbe..3899007fe 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -95,6 +95,7 @@ endif() create_directory_groups(${SRCS} ${HEADERS}) add_library(common STATIC ${SRCS} ${HEADERS}) +target_link_libraries(common PUBLIC Boost::boost) if (ARCHITECTURE_x86_64) target_link_libraries(common PRIVATE xbyak) endif() diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 7aa81e885..acc261e31 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -381,4 +381,4 @@ create_directory_groups(${SRCS} ${HEADERS}) add_library(core STATIC ${SRCS} ${HEADERS}) target_link_libraries(core PUBLIC common PRIVATE audio_core video_core) -target_link_libraries(core PRIVATE cryptopp dynarmic) +target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp dynarmic) From d6ff5c6f7568d05c2f675b5424780682bd10bad6 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 20:43:58 -0700 Subject: [PATCH 04/15] CMake: Use append instead of set to modify list --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9deb590b7..e8dc95505 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,6 +1,6 @@ # CMake 3.6 required for FindBoost to define IMPORTED libs properly on unknown Boost versions cmake_minimum_required(VERSION 3.6) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules) +list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules") function(download_bundled_external remote_path lib_name prefix_var) set(prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}") From 089baa04e851676c1c04e640ef137b9025d6e5dc Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 19:46:26 -0700 Subject: [PATCH 05/15] CMake: Stop using FindOpenGL, which seems to not be required anymore --- CMakeLists.txt | 3 --- externals/glad/CMakeLists.txt | 3 ++- src/citra/CMakeLists.txt | 2 +- src/citra_qt/CMakeLists.txt | 2 +- 4 files changed, 4 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e8dc95505..5fd63fd16 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -147,9 +147,6 @@ endif() # Include bundled CMake modules list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules") -find_package(OpenGL REQUIRED) -include_directories(${OPENGL_INCLUDE_DIR}) - # Prefer the -pthread flag on Linux. set (THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) diff --git a/externals/glad/CMakeLists.txt b/externals/glad/CMakeLists.txt index a97d4aa73..6d35a844b 100644 --- a/externals/glad/CMakeLists.txt +++ b/externals/glad/CMakeLists.txt @@ -9,6 +9,7 @@ set(HEADERS create_directory_groups(${SRCS} ${HEADERS}) add_library(glad STATIC ${SRCS} ${HEADERS}) target_include_directories(glad PUBLIC "include/") + if ("${CMAKE_SYSTEM_NAME}" MATCHES "Linux") - target_link_libraries(glad dl) + target_link_libraries(glad PRIVATE dl) endif() diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index 9eddb342b..f6f2e8e91 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -19,7 +19,7 @@ include_directories(${SDL2_INCLUDE_DIR}) add_executable(citra ${SRCS} ${HEADERS}) target_link_libraries(citra PRIVATE common core input_common) -target_link_libraries(citra PRIVATE ${SDL2_LIBRARY} ${OPENGL_gl_LIBRARY} inih glad) +target_link_libraries(citra PRIVATE ${SDL2_LIBRARY} inih glad) if (MSVC) target_link_libraries(citra PRIVATE getopt) endif() diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index e2b77a34f..839ce600b 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -92,7 +92,7 @@ else() add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) endif() target_link_libraries(citra-qt PRIVATE audio_core common core input_common video_core) -target_link_libraries(citra-qt PRIVATE ${OPENGL_gl_LIBRARY} ${CITRA_QT_LIBS} Boost::boost glad) +target_link_libraries(citra-qt PRIVATE ${CITRA_QT_LIBS} Boost::boost glad) target_link_libraries(citra-qt PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) if(UNIX AND NOT APPLE) From 34b6c8bd8853964fde3bcff95150af561415c26c Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 20:53:39 -0700 Subject: [PATCH 06/15] CMake: Remove CITRA_QT_LIBS var This used to be required to support both Qt4 and Qt5, but we dropped Qt4 so it's not needed anymore. --- CMakeLists.txt | 1 - src/citra_qt/CMakeLists.txt | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 5fd63fd16..238e92dcc 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -223,7 +223,6 @@ if (ENABLE_QT) endif() find_package(Qt5 REQUIRED COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT}) - set(CITRA_QT_LIBS Qt5::Widgets Qt5::OpenGL) endif() # This function should be passed a list of all files in a target. It will automatically generate diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index 839ce600b..a70686286 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -92,7 +92,7 @@ else() add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) endif() target_link_libraries(citra-qt PRIVATE audio_core common core input_common video_core) -target_link_libraries(citra-qt PRIVATE ${CITRA_QT_LIBS} Boost::boost glad) +target_link_libraries(citra-qt PRIVATE Boost::boost glad Qt5::OpenGL Qt5::Widgets) target_link_libraries(citra-qt PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) if(UNIX AND NOT APPLE) From 776cb917850c9d36ffd886de2dc93f6b42b879db Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 21:38:49 -0700 Subject: [PATCH 07/15] CMake: Define an interface target for SDL2 definitions --- CMakeLists.txt | 7 +++++++ src/audio_core/CMakeLists.txt | 3 +-- src/citra/CMakeLists.txt | 6 ++---- src/input_common/CMakeLists.txt | 3 +-- 4 files changed, 11 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 238e92dcc..b746554fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -171,6 +171,13 @@ if (ENABLE_SDL2) else() find_package(SDL2 REQUIRED) endif() + + if (SDL2_FOUND) + # TODO(yuriks): Make FindSDL2.cmake export an IMPORTED library instead + add_library(SDL2 INTERFACE) + target_link_libraries(SDL2 INTERFACE "${SDL2_LIBRARY}") + target_include_directories(SDL2 INTERFACE "${SDL2_INCLUDE_DIR}") + endif() else() set(SDL2_FOUND NO) endif() diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index c571213fc..ecd3025cc 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -32,7 +32,6 @@ include_directories(../../externals/soundtouch/include) if(SDL2_FOUND) set(SRCS ${SRCS} sdl2_sink.cpp) set(HEADERS ${HEADERS} sdl2_sink.h) - include_directories(${SDL2_INCLUDE_DIR}) endif() create_directory_groups(${SRCS} ${HEADERS}) @@ -42,6 +41,6 @@ target_link_libraries(audio_core PUBLIC common core) target_link_libraries(audio_core PRIVATE SoundTouch) if(SDL2_FOUND) - target_link_libraries(audio_core PRIVATE ${SDL2_LIBRARY}) + target_link_libraries(audio_core PRIVATE SDL2) target_compile_definitions(audio_core PRIVATE HAVE_SDL2) endif() diff --git a/src/citra/CMakeLists.txt b/src/citra/CMakeLists.txt index f6f2e8e91..d72d2b5f4 100644 --- a/src/citra/CMakeLists.txt +++ b/src/citra/CMakeLists.txt @@ -15,15 +15,13 @@ set(HEADERS create_directory_groups(${SRCS} ${HEADERS}) -include_directories(${SDL2_INCLUDE_DIR}) - add_executable(citra ${SRCS} ${HEADERS}) target_link_libraries(citra PRIVATE common core input_common) -target_link_libraries(citra PRIVATE ${SDL2_LIBRARY} inih glad) +target_link_libraries(citra PRIVATE inih glad) if (MSVC) target_link_libraries(citra PRIVATE getopt) endif() -target_link_libraries(citra PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) +target_link_libraries(citra PRIVATE ${PLATFORM_LIBRARIES} SDL2 Threads::Threads) if(UNIX AND NOT APPLE) install(TARGETS citra RUNTIME DESTINATION "${CMAKE_INSTALL_PREFIX}/bin") diff --git a/src/input_common/CMakeLists.txt b/src/input_common/CMakeLists.txt index 5b306e42e..e3e36ada7 100644 --- a/src/input_common/CMakeLists.txt +++ b/src/input_common/CMakeLists.txt @@ -13,7 +13,6 @@ set(HEADERS if(SDL2_FOUND) set(SRCS ${SRCS} sdl/sdl.cpp) set(HEADERS ${HEADERS} sdl/sdl.h) - include_directories(${SDL2_INCLUDE_DIR}) endif() create_directory_groups(${SRCS} ${HEADERS}) @@ -22,6 +21,6 @@ add_library(input_common STATIC ${SRCS} ${HEADERS}) target_link_libraries(input_common PUBLIC core PRIVATE common) if(SDL2_FOUND) - target_link_libraries(input_common PRIVATE ${SDL2_LIBRARY}) + target_link_libraries(input_common PRIVATE SDL2) target_compile_definitions(input_common PRIVATE HAVE_SDL2) endif() From cb49df156d080901735731efeb9277ed05bd9124 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 21:59:02 -0700 Subject: [PATCH 08/15] CMake: Use target properties to add inih include paths --- CMakeLists.txt | 4 +--- externals/inih/CMakeLists.txt | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b746554fe..6376862ca 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -254,9 +254,7 @@ get_git_head_revision(GIT_REF_SPEC GIT_REV) git_describe(GIT_DESC --always --long --dirty) git_branch_name(GIT_BRANCH) -set(INI_PREFIX "${CMAKE_CURRENT_SOURCE_DIR}/externals/inih") -include_directories(${INI_PREFIX}) -add_subdirectory(${INI_PREFIX}) +add_subdirectory(externals/inih) add_subdirectory(externals) diff --git a/externals/inih/CMakeLists.txt b/externals/inih/CMakeLists.txt index c87f78bfc..cff36a581 100644 --- a/externals/inih/CMakeLists.txt +++ b/externals/inih/CMakeLists.txt @@ -9,3 +9,4 @@ set(HEADERS create_directory_groups(${SRCS} ${HEADERS}) add_library(inih ${SRCS} ${HEADERS}) +target_include_directories(inih INTERFACE .) From 74afcd53286f0cae1782f7449084192f6b8619ff Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 22:09:28 -0700 Subject: [PATCH 09/15] CMake: Add SoundTouch include path to target property --- CMakeLists.txt | 2 ++ src/audio_core/CMakeLists.txt | 2 -- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 6376862ca..7f099fd34 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -272,6 +272,8 @@ endif() # process subdirectories add_subdirectory(externals/soundtouch) +# The SoundTouch target doesn't export the necessary include paths as properties by default +target_include_directories(SoundTouch INTERFACE "externals/soundtouch/include") enable_testing() diff --git a/src/audio_core/CMakeLists.txt b/src/audio_core/CMakeLists.txt index ecd3025cc..0ad86bb7a 100644 --- a/src/audio_core/CMakeLists.txt +++ b/src/audio_core/CMakeLists.txt @@ -27,8 +27,6 @@ set(HEADERS time_stretch.h ) -include_directories(../../externals/soundtouch/include) - if(SDL2_FOUND) set(SRCS ${SRCS} sdl2_sink.cpp) set(HEADERS ${HEADERS} sdl2_sink.h) From 4f84372bc20bbdc7a14e6d49edd1fda498a3ec54 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 22:16:57 -0700 Subject: [PATCH 10/15] CMake: Add cryptopp include path to target property --- externals/cryptopp/CMakeLists.txt | 6 ++++-- src/core/CMakeLists.txt | 1 - 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/externals/cryptopp/CMakeLists.txt b/externals/cryptopp/CMakeLists.txt index 653af1e4b..864de18bb 100644 --- a/externals/cryptopp/CMakeLists.txt +++ b/externals/cryptopp/CMakeLists.txt @@ -10,6 +10,7 @@ # - disabled installation # - disabled documentation # - configured to build a static library only +# - adds include directories to the library target include(TestBigEndian) include(CheckCXXCompilerFlag) @@ -148,14 +149,15 @@ endif() # Compile targets #============================================================================ add_library(cryptopp STATIC ${cryptopp_SOURCES}) +target_include_directories(cryptopp INTERFACE .) #============================================================================ # Third-party libraries #============================================================================ if(WIN32) - target_link_libraries(cryptopp ws2_32) + target_link_libraries(cryptopp PRIVATE ws2_32) endif() find_package(Threads) -target_link_libraries(cryptopp ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(cryptopp PRIVATE ${CMAKE_THREAD_LIBS_INIT}) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index acc261e31..31152abd5 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -375,7 +375,6 @@ set(HEADERS ) include_directories(../../externals/dynarmic/include) -include_directories(../../externals/cryptopp) create_directory_groups(${SRCS} ${HEADERS}) From 3b68600f81078c5cc56f8697746d9ea5a4281d76 Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 22:19:37 -0700 Subject: [PATCH 11/15] CMake: Remove unnecessary include_directories for dynarmic Dynarmic already adds the correct include paths to the library target. --- src/core/CMakeLists.txt | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/core/CMakeLists.txt b/src/core/CMakeLists.txt index 31152abd5..3cdb2b817 100644 --- a/src/core/CMakeLists.txt +++ b/src/core/CMakeLists.txt @@ -374,10 +374,7 @@ set(HEADERS telemetry_session.h ) -include_directories(../../externals/dynarmic/include) - create_directory_groups(${SRCS} ${HEADERS}) - add_library(core STATIC ${SRCS} ${HEADERS}) target_link_libraries(core PUBLIC common PRIVATE audio_core video_core) target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp dynarmic) From d736cca848a12788652e366b5554063c99f06cca Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 22:34:52 -0700 Subject: [PATCH 12/15] CMake: Create INTERFACE targets for microprofile and nihstro --- CMakeLists.txt | 8 ++++++-- src/citra_qt/CMakeLists.txt | 2 +- src/common/CMakeLists.txt | 2 +- src/video_core/CMakeLists.txt | 2 +- 4 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7f099fd34..9e586633c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -263,8 +263,12 @@ set(DYNARMIC_NO_BUNDLED_FMT ON) add_subdirectory(externals/dynarmic) add_subdirectory(externals/glad) -include_directories(externals/microprofile) -include_directories(externals/nihstro/include) + +add_library(microprofile INTERFACE) +target_include_directories(microprofile INTERFACE externals/microprofile) + +add_library(nihstro-headers INTERFACE) +target_include_directories(nihstro-headers INTERFACE externals/nihstro/include) if (MSVC) add_subdirectory(externals/getopt) diff --git a/src/citra_qt/CMakeLists.txt b/src/citra_qt/CMakeLists.txt index a70686286..4841cbf05 100644 --- a/src/citra_qt/CMakeLists.txt +++ b/src/citra_qt/CMakeLists.txt @@ -92,7 +92,7 @@ else() add_executable(citra-qt ${SRCS} ${HEADERS} ${UI_HDRS}) endif() target_link_libraries(citra-qt PRIVATE audio_core common core input_common video_core) -target_link_libraries(citra-qt PRIVATE Boost::boost glad Qt5::OpenGL Qt5::Widgets) +target_link_libraries(citra-qt PRIVATE Boost::boost glad nihstro-headers Qt5::OpenGL Qt5::Widgets) target_link_libraries(citra-qt PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) if(UNIX AND NOT APPLE) diff --git a/src/common/CMakeLists.txt b/src/common/CMakeLists.txt index 3899007fe..7e83e64b0 100644 --- a/src/common/CMakeLists.txt +++ b/src/common/CMakeLists.txt @@ -95,7 +95,7 @@ endif() create_directory_groups(${SRCS} ${HEADERS}) add_library(common STATIC ${SRCS} ${HEADERS}) -target_link_libraries(common PUBLIC Boost::boost) +target_link_libraries(common PUBLIC Boost::boost microprofile) if (ARCHITECTURE_x86_64) target_link_libraries(common PRIVATE xbyak) endif() diff --git a/src/video_core/CMakeLists.txt b/src/video_core/CMakeLists.txt index 45f4ad2d5..0961a3251 100644 --- a/src/video_core/CMakeLists.txt +++ b/src/video_core/CMakeLists.txt @@ -80,7 +80,7 @@ create_directory_groups(${SRCS} ${HEADERS}) add_library(video_core STATIC ${SRCS} ${HEADERS}) target_link_libraries(video_core PUBLIC common core) -target_link_libraries(video_core PRIVATE glad) +target_link_libraries(video_core PRIVATE glad nihstro-headers) if (ARCHITECTURE_x86_64) target_link_libraries(video_core PRIVATE xbyak) From cebdae6c92f56b4e56b4aedd5d65c7fff0c7e44f Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 22:46:59 -0700 Subject: [PATCH 13/15] CMake: Create an INTERFACE target for Catch --- externals/CMakeLists.txt | 4 ++++ src/tests/CMakeLists.txt | 6 ++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index 57fc5d566..db70eecd9 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -1,3 +1,7 @@ +# Catch +add_library(catch-single-include INTERFACE) +target_include_directories(catch-single-include INTERFACE catch/single_include) + # Xbyak if (ARCHITECTURE_x86_64) add_library(xbyak INTERFACE) diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 85f2f2985..00d7c636a 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -10,11 +10,9 @@ set(HEADERS create_directory_groups(${SRCS} ${HEADERS}) -include_directories(../../externals/catch/single_include/) - add_executable(tests ${SRCS} ${HEADERS}) target_link_libraries(tests PRIVATE common core) target_link_libraries(tests PRIVATE glad) # To support linker work-around -target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} Threads::Threads) +target_link_libraries(tests PRIVATE ${PLATFORM_LIBRARIES} catch-single-include Threads::Threads) -add_test(NAME tests COMMAND $) +add_test(NAME tests COMMAND tests) From c21136873402ab83689aec26e61dc0e163d1002f Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 23:33:14 -0700 Subject: [PATCH 14/15] CMake: Move definitions of externals to the CMakeLists in that directory --- CMakeLists.txt | 31 +++++--------------------- externals/CMakeLists.txt | 48 +++++++++++++++++++++++++++++++++++----- 2 files changed, 47 insertions(+), 32 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9e586633c..79dd54d52 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -2,6 +2,10 @@ cmake_minimum_required(VERSION 3.6) list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules") +# This function downloads a binary library package from our external repo. +# Params: +# remote_path: path to the file to download, relative to the remote repository root +# prefix_var: name of a variable which will be set with the path to the extracted contents function(download_bundled_external remote_path lib_name prefix_var) set(prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}") if (NOT EXISTS "${prefix}") @@ -254,34 +258,9 @@ get_git_head_revision(GIT_REF_SPEC GIT_REV) git_describe(GIT_DESC --always --long --dirty) git_branch_name(GIT_BRANCH) -add_subdirectory(externals/inih) - add_subdirectory(externals) - -option(DYNARMIC_TESTS OFF) -set(DYNARMIC_NO_BUNDLED_FMT ON) -add_subdirectory(externals/dynarmic) - -add_subdirectory(externals/glad) - -add_library(microprofile INTERFACE) -target_include_directories(microprofile INTERFACE externals/microprofile) - -add_library(nihstro-headers INTERFACE) -target_include_directories(nihstro-headers INTERFACE externals/nihstro/include) - -if (MSVC) - add_subdirectory(externals/getopt) -endif() - -# process subdirectories -add_subdirectory(externals/soundtouch) -# The SoundTouch target doesn't export the necessary include paths as properties by default -target_include_directories(SoundTouch INTERFACE "externals/soundtouch/include") - -enable_testing() - add_subdirectory(src) +enable_testing() # Install freedesktop.org metadata files, following those specifications: # http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html diff --git a/externals/CMakeLists.txt b/externals/CMakeLists.txt index db70eecd9..1e04931ee 100644 --- a/externals/CMakeLists.txt +++ b/externals/CMakeLists.txt @@ -1,16 +1,52 @@ +# Definitions for all external bundled libraries + # Catch add_library(catch-single-include INTERFACE) target_include_directories(catch-single-include INTERFACE catch/single_include) +# Crypto++ +add_subdirectory(cryptopp) + +# Dynarmic +# Dynarmic will skip defining xbyak if it's already defined, we then define it below +add_library(xbyak INTERFACE) +option(DYNARMIC_TESTS OFF) +set(DYNARMIC_NO_BUNDLED_FMT ON) +add_subdirectory(dynarmic) + +# libfmt +add_subdirectory(fmt) + +# getopt +if (MSVC) + add_subdirectory(getopt) +endif() + +# Glad +add_subdirectory(glad) + +# inih +add_subdirectory(inih) + +# MicroProfile +add_library(microprofile INTERFACE) +target_include_directories(microprofile INTERFACE ./microprofile) + +# Nihstro +add_library(nihstro-headers INTERFACE) +target_include_directories(nihstro-headers INTERFACE ./nihstro/include) + +# SoundTouch +add_subdirectory(soundtouch) +# The SoundTouch target doesn't export the necessary include paths as properties by default +target_include_directories(SoundTouch INTERFACE ./soundtouch/include) + # Xbyak if (ARCHITECTURE_x86_64) - add_library(xbyak INTERFACE) - target_include_directories(xbyak INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}/xbyak/xbyak) + # Defined before "dynarmic" above + # add_library(xbyak INTERFACE) + target_include_directories(xbyak INTERFACE ./xbyak/xbyak) if (NOT MSVC) target_compile_options(xbyak INTERFACE -fno-operator-names) endif() endif() - -add_subdirectory(cryptopp) - -add_subdirectory(fmt) From 9a08160ae5bf62ef687999883461669dce8ef0cd Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Sat, 27 May 2017 23:45:55 -0700 Subject: [PATCH 15/15] CMake: Re-organize root CMakeLists.txt file Separates the file into sections and re-orders things to fit in them --- CMakeLists.txt | 134 ++++++++++++++++++++++++++++--------------------- 1 file changed, 78 insertions(+), 56 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 79dd54d52..1f0af2d41 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,24 +1,25 @@ # CMake 3.6 required for FindBoost to define IMPORTED libs properly on unknown Boost versions cmake_minimum_required(VERSION 3.6) -list(APPEND CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/CMakeModules") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules") -# This function downloads a binary library package from our external repo. -# Params: -# remote_path: path to the file to download, relative to the remote repository root -# prefix_var: name of a variable which will be set with the path to the extracted contents -function(download_bundled_external remote_path lib_name prefix_var) - set(prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}") - if (NOT EXISTS "${prefix}") - message(STATUS "Downloading binaries for ${lib_name}...") - file(DOWNLOAD - https://github.com/citra-emu/ext-windows-bin/raw/master/${remote_path}${lib_name}.7z - "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" SHOW_PROGRESS) - execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" - WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals") - endif() - message(STATUS "Using bundled binaries at ${prefix}") - set(${prefix_var} "${prefix}" PARENT_SCOPE) -endfunction() +project(citra) + +option(ENABLE_SDL2 "Enable the SDL2 frontend" ON) +option(CITRA_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF) + +option(ENABLE_QT "Enable the Qt frontend" ON) +option(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF) + +if(NOT EXISTS ${CMAKE_SOURCE_DIR}/.git/hooks/pre-commit) + message(STATUS "Copying pre-commit hook") + file(COPY hooks/pre-commit + DESTINATION ${CMAKE_SOURCE_DIR}/.git/hooks) +endif() + + +# Detect current compilation architecture and create standard definitions +# ======================================================================= include(CheckSymbolExists) function(detect_architecture symbol arch) @@ -37,20 +38,6 @@ function(detect_architecture symbol arch) endif() endfunction() -project(citra) - -option(ENABLE_SDL2 "Enable the SDL2 frontend" ON) -option(CITRA_USE_BUNDLED_SDL2 "Download bundled SDL2 binaries" OFF) - -option(ENABLE_QT "Enable the Qt frontend" ON) -option(CITRA_USE_BUNDLED_QT "Download bundled Qt binaries" OFF) - -if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks/pre-commit) - message(STATUS "Copying pre-commit hook") - file(COPY hooks/pre-commit - DESTINATION ${CMAKE_CURRENT_SOURCE_DIR}/.git/hooks) -endif() - if (MSVC) detect_architecture("_M_AMD64" x86_64) detect_architecture("_M_IX86" x86) @@ -67,6 +54,10 @@ if (NOT DEFINED ARCHITECTURE) endif() message(STATUS "Target architecture: ${ARCHITECTURE}") + +# Configure compilation flags +# =========================== + set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) @@ -134,6 +125,28 @@ add_definitions(-DSINGLETHREADED) set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS $<$:_DEBUG> $<$>:NDEBUG>) + +# System imported libraries +# ====================== + +# This function downloads a binary library package from our external repo. +# Params: +# remote_path: path to the file to download, relative to the remote repository root +# prefix_var: name of a variable which will be set with the path to the extracted contents +function(download_bundled_external remote_path lib_name prefix_var) + set(prefix "${CMAKE_BINARY_DIR}/externals/${lib_name}") + if (NOT EXISTS "${prefix}") + message(STATUS "Downloading binaries for ${lib_name}...") + file(DOWNLOAD + https://github.com/citra-emu/ext-windows-bin/raw/master/${remote_path}${lib_name}.7z + "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" SHOW_PROGRESS) + execute_process(COMMAND ${CMAKE_COMMAND} -E tar xf "${CMAKE_BINARY_DIR}/externals/${lib_name}.7z" + WORKING_DIRECTORY "${CMAKE_BINARY_DIR}/externals") + endif() + message(STATUS "Using bundled binaries at ${prefix}") + set(${prefix_var} "${prefix}" PARENT_SCOPE) +endfunction() + find_package(PNG QUIET) if (NOT PNG_FOUND) message(STATUS "libpng not found. Some debugging features have been disabled.") @@ -148,11 +161,8 @@ if (NOT Boost_FOUND) find_package(Boost QUIET REQUIRED) endif() -# Include bundled CMake modules -list(APPEND CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/externals/cmake-modules") - # Prefer the -pthread flag on Linux. -set (THREADS_PREFER_PTHREAD_FLAG ON) +set(THREADS_PREFER_PTHREAD_FLAG ON) find_package(Threads REQUIRED) if (ENABLE_SDL2) @@ -186,6 +196,32 @@ else() set(SDL2_FOUND NO) endif() +if (ENABLE_QT) + if (CITRA_USE_BUNDLED_QT) + if (MSVC14 AND ARCHITECTURE_x86_64) + set(QT_VER qt-5.7-msvc2015_64) + else() + message(FATAL_ERROR "No bundled Qt binaries for your toolchain. Disable CITRA_USE_BUNDLED_QT and provide your own.") + endif() + + if (DEFINED QT_VER) + download_bundled_external("qt/" ${QT_VER} QT_PREFIX) + endif() + + set(QT_PREFIX_HINT HINTS "${QT_PREFIX}") + else() + # Passing an empty HINTS seems to cause default system paths to get ignored in CMake 2.8 so + # make sure to not pass anything if we don't have one. + set(QT_PREFIX_HINT) + endif() + + find_package(Qt5 REQUIRED COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT}) +endif() + + +# Platform-specific library requirements +# ====================================== + IF (APPLE) FIND_LIBRARY(COCOA_LIBRARY Cocoa) # Umbrella framework for everything GUI-related set(PLATFORM_LIBRARIES ${COCOA_LIBRARY} ${IOKIT_LIBRARY} ${COREVIDEO_LIBRARY}) @@ -214,27 +250,9 @@ if (UNIX OR MINGW) endif() endif() -if (ENABLE_QT) - if (CITRA_USE_BUNDLED_QT) - if (MSVC14 AND ARCHITECTURE_x86_64) - set(QT_VER qt-5.7-msvc2015_64) - else() - message(FATAL_ERROR "No bundled Qt binaries for your toolchain. Disable CITRA_USE_BUNDLED_QT and provide your own.") - endif() - if (DEFINED QT_VER) - download_bundled_external("qt/" ${QT_VER} QT_PREFIX) - endif() - - set(QT_PREFIX_HINT HINTS "${QT_PREFIX}") - else() - # Passing an empty HINTS seems to cause default system paths to get ignored in CMake 2.8 so - # make sure to not pass anything if we don't have one. - set(QT_PREFIX_HINT) - endif() - - find_package(Qt5 REQUIRED COMPONENTS Widgets OpenGL ${QT_PREFIX_HINT}) -endif() +# Include source code +# =================== # This function should be passed a list of all files in a target. It will automatically generate # file groups following the directory hierarchy, so that the layout of the files in IDEs matches the @@ -262,6 +280,10 @@ add_subdirectory(externals) add_subdirectory(src) enable_testing() + +# Installation instructions +# ========================= + # Install freedesktop.org metadata files, following those specifications: # http://standards.freedesktop.org/desktop-entry-spec/desktop-entry-spec-latest.html # http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html