diff --git a/CMakeLists.txt b/CMakeLists.txt index 77dc5545..de5f01c4 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -14,6 +14,18 @@ include(GetGitRevisionDescription) get_git_head_revision(GIT_REFSPEC GIT_SHA1) message(STATUS "Building ${CMAKE_PROJECT_NAME} GIT SHA1: ${GIT_SHA1}") +find_package(Boost REQUIRED) +find_package(Boost COMPONENTS program_options system REQUIRED) +if(FILESYSTEM_LIBRARY STREQUAL "BOOST") + find_package(Boost COMPONENTS filesystem system REQUIRED) +endif() +if(BUILD_TESTS) + find_package(Boost COMPONENTS unit_test_framework REQUIRED) +endif() +if(CHECK_INCLUDES) + find_package(IncludeWhatYouUse REQUIRED) +endif() + set(OpenGL_GL_PREFERENCE GLVND) find_package(OpenGL REQUIRED) find_package(OpenAL REQUIRED) @@ -26,6 +38,10 @@ if(CHECK_CLANGTIDY) find_package(ClangTidy REQUIRED) endif() +if(CHECK_IWYU) + find_package(IncludeWhatYouUse REQUIRED) +endif() + # Create a rw_interface TARGET that holds all compiler options include("${PROJECT_SOURCE_DIR}/cmake_configure.cmake") diff --git a/cmake_configure.cmake b/cmake_configure.cmake index 53e1a83d..41e81bd1 100644 --- a/cmake_configure.cmake +++ b/cmake_configure.cmake @@ -72,7 +72,6 @@ elseif(FILESYSTEM_LIBRARY STREQUAL "CXXTS") target_link_libraries(rw_interface INTERFACE "stdc++fs") endif() elseif(FILESYSTEM_LIBRARY STREQUAL "BOOST") - find_package(Boost COMPONENTS system filesystem REQUIRED) target_compile_definitions(rw_interface INTERFACE "RW_FS_LIBRARY=2") target_include_directories(rw_interface INTERFACE ${Boost_INCLUDE_DIRS}) target_link_libraries(rw_interface INTERFACE @@ -145,10 +144,6 @@ endforeach() include(CMakeParseArguments) -if(CHECK_IWYU) - find_package(IncludeWhatYouUse REQUIRED) -endif() - function(openrw_target_apply_options) set(IWYU_MAPPING "${PROJECT_SOURCE_DIR}/openrw_iwyu.imp") cmake_parse_arguments("OPENRW_APPLY" "" "TARGET" "" ${ARGN}) diff --git a/rwgame/CMakeLists.txt b/rwgame/CMakeLists.txt index cf871476..4c82f405 100644 --- a/rwgame/CMakeLists.txt +++ b/rwgame/CMakeLists.txt @@ -1,5 +1,3 @@ -find_package(Boost COMPONENTS program_options REQUIRED) - configure_file("${CMAKE_CURRENT_SOURCE_DIR}/GitSHA1.cpp.in" "${CMAKE_CURRENT_BINARY_DIR}/GitSHA1.cpp" @ONLY) set(RWGAME_SOURCES diff --git a/rwlib/CMakeLists.txt b/rwlib/CMakeLists.txt index e249bb92..70f73cf4 100644 --- a/rwlib/CMakeLists.txt +++ b/rwlib/CMakeLists.txt @@ -2,8 +2,6 @@ ## RWLIB ########################################################### -find_package(Boost REQUIRED) - SET(RWLIB_SOURCES # GL stuff is only here temporarily, hoping to move it back to rwengine source/gl/gl_core_3_3.c diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt index 99ec944a..b675c404 100644 --- a/tests/CMakeLists.txt +++ b/tests/CMakeLists.txt @@ -2,8 +2,6 @@ # Unit Tests ############################################################################## -find_package(Boost COMPONENTS filesystem unit_test_framework system REQUIRED) - set(TESTS Animation Archive