Change how the boost target works; disable external warnings in MSVC
This commit is contained in:
parent
a0ac302a93
commit
9877bf7d48
|
@ -1,5 +1,6 @@
|
|||
# CMake 3.8 required for 17 to be a valid value for CXX_STANDARD
|
||||
cmake_minimum_required(VERSION 3.8)
|
||||
cmake_policy(SET CMP0092 NEW)
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/CMakeModules")
|
||||
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/externals/cmake-modules")
|
||||
include(DownloadExternals)
|
||||
|
@ -35,6 +36,8 @@ CMAKE_DEPENDENT_OPTION(ENABLE_MF "Use Media Foundation decoder (preferred over F
|
|||
|
||||
CMAKE_DEPENDENT_OPTION(COMPILE_WITH_DWARF "Add DWARF debugging information" ON "MINGW" OFF)
|
||||
|
||||
option(USE_SYSTEM_BOOST "Use the system Boost libs (instead of the bundled ones)" OFF)
|
||||
|
||||
if(NOT EXISTS ${PROJECT_SOURCE_DIR}/.git/hooks/pre-commit)
|
||||
message(STATUS "Copying pre-commit hook")
|
||||
file(COPY hooks/pre-commit
|
||||
|
@ -124,25 +127,6 @@ set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${PROJECT_BINARY_DIR}/bin)
|
|||
# System imported libraries
|
||||
# ======================
|
||||
|
||||
add_library(boost_libs INTERFACE)
|
||||
|
||||
find_package(Boost 1.70.0 QUIET EXACT)
|
||||
if (NOT Boost_FOUND)
|
||||
message(STATUS "Boost 1.70.0 not found, falling back to externals")
|
||||
|
||||
set(BOOST_ROOT "${PROJECT_SOURCE_DIR}/externals/boost")
|
||||
set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/boost")
|
||||
set(Boost_NO_SYSTEM_PATHS ON)
|
||||
add_definitions( -DBOOST_ALL_NO_LIB )
|
||||
find_package(Boost QUIET REQUIRED)
|
||||
|
||||
# Boost external libraries
|
||||
file(GLOB boost_serialization_SRC "externals/boost/libs/serialization/src/*.cpp")
|
||||
add_library(boost_serialization STATIC ${boost_serialization_SRC})
|
||||
target_link_libraries(boost_serialization PUBLIC Boost::boost)
|
||||
target_link_libraries(boost_libs INTERFACE boost_serialization)
|
||||
endif()
|
||||
|
||||
# Prefer the -pthread flag on Linux.
|
||||
set(THREADS_PREFER_PTHREAD_FLAG ON)
|
||||
find_package(Threads REQUIRED)
|
||||
|
@ -340,8 +324,21 @@ git_describe(GIT_DESC --always --long --dirty)
|
|||
git_branch_name(GIT_BRANCH)
|
||||
get_timestamp(BUILD_DATE)
|
||||
|
||||
if (NOT USE_SYSTEM_BOOST)
|
||||
add_definitions( -DBOOST_ALL_NO_LIB )
|
||||
endif()
|
||||
|
||||
enable_testing()
|
||||
add_subdirectory(externals)
|
||||
|
||||
# Boost
|
||||
if (USE_SYSTEM_BOOST)
|
||||
find_package(Boost 1.70.0 QUIET REQUIRED)
|
||||
else()
|
||||
add_library(Boost::boost ALIAS boost)
|
||||
add_library(Boost::serialization ALIAS boost_serialization)
|
||||
endif()
|
||||
|
||||
add_subdirectory(src)
|
||||
add_subdirectory(dist/installer)
|
||||
|
||||
|
|
|
@ -1,9 +1,28 @@
|
|||
# Definitions for all external bundled libraries
|
||||
|
||||
# Suppress warnings from external libraries
|
||||
if (CMAKE_C_COMPILER_ID MATCHES "MSVC")
|
||||
add_compile_options(/W0)
|
||||
endif()
|
||||
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/CMakeModules)
|
||||
include(DownloadExternals)
|
||||
include(ExternalProject)
|
||||
|
||||
# Boost
|
||||
set(BOOST_ROOT "${CMAKE_SOURCE_DIR}/externals/boost")
|
||||
set(Boost_INCLUDE_DIR "${CMAKE_SOURCE_DIR}/externals/boost")
|
||||
set(Boost_NO_SYSTEM_PATHS ON)
|
||||
add_library(boost INTERFACE)
|
||||
target_include_directories(boost SYSTEM INTERFACE ${Boost_INCLUDE_DIR})
|
||||
|
||||
# Boost::serialization
|
||||
file(GLOB boost_serialization_SRC "${CMAKE_SOURCE_DIR}/externals/boost/libs/serialization/src/*.cpp")
|
||||
add_library(boost_serialization STATIC ${boost_serialization_SRC})
|
||||
target_link_libraries(boost_serialization PUBLIC boost)
|
||||
|
||||
# Add additional boost libs here; remember to ALIAS them in the root CMakeLists!
|
||||
|
||||
# Catch
|
||||
add_library(catch-single-include INTERFACE)
|
||||
target_include_directories(catch-single-include INTERFACE catch/single_include)
|
||||
|
|
|
@ -37,7 +37,7 @@ if (MSVC)
|
|||
/Zo
|
||||
/permissive-
|
||||
/EHsc
|
||||
/std:c++latest
|
||||
/std:c++17
|
||||
/volatile:iso
|
||||
/Zc:externConstexpr
|
||||
/Zc:inline
|
||||
|
@ -46,6 +46,10 @@ if (MSVC)
|
|||
add_compile_options(
|
||||
/MP
|
||||
/Zc:throwingNew
|
||||
/experimental:external
|
||||
/external:I "${CMAKE_SOURCE_DIR}/externals"
|
||||
/external:anglebrackets
|
||||
/external:W0
|
||||
)
|
||||
endif()
|
||||
|
||||
|
|
|
@ -466,7 +466,7 @@ endif()
|
|||
create_target_directory_groups(core)
|
||||
|
||||
target_link_libraries(core PUBLIC common PRIVATE audio_core network video_core)
|
||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives boost_libs)
|
||||
target_link_libraries(core PUBLIC Boost::boost PRIVATE cryptopp fmt open_source_archives Boost::serialization)
|
||||
if (ENABLE_WEB_SERVICE)
|
||||
target_compile_definitions(core PRIVATE -DENABLE_WEB_SERVICE)
|
||||
target_link_libraries(core PRIVATE web_service)
|
||||
|
|
|
@ -94,7 +94,7 @@ endif()
|
|||
create_target_directory_groups(video_core)
|
||||
|
||||
target_link_libraries(video_core PUBLIC common core)
|
||||
target_link_libraries(video_core PRIVATE glad nihstro-headers boost_libs)
|
||||
target_link_libraries(video_core PRIVATE glad nihstro-headers Boost::serialization)
|
||||
|
||||
if (ARCHITECTURE_x86_64)
|
||||
target_link_libraries(video_core PUBLIC xbyak)
|
||||
|
|
Reference in New Issue