diff --git a/CMakeLists.txt b/CMakeLists.txt index 39e3716c5d06ecdcd714be0091ae797d3ec2072d..6a889ee6fd590de4e3e8bc892b8f5e5449be66fe 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -22,10 +22,7 @@ endif() # Project name project( OGS-6 ) -list(APPEND CMAKE_PREFIX_PATH - $ENV{HOMEBREW_ROOT} # Homebrew package manager on Mac OS - $ENV{CMAKE_LIBRARY_SEARCH_PATH} # Environment variable, Windows - ${CMAKE_LIBRARY_SEARCH_PATH}) # CMake option, Windows +include(scripts/cmake/CMakeSetup.cmake) ########################### ### Preliminary Options ### @@ -49,22 +46,21 @@ if(OGS_USE_PETSC) endif() ### CMake includes ### -include(scripts/cmake/PreFind.cmake) -include(scripts/cmake/CheckTypeSizes.cmake) -include(scripts/cmake/Functions.cmake) -include(scripts/cmake/SubmoduleSetup.cmake) -include(scripts/cmake/CMakeSetup.cmake) -include(scripts/cmake/ConanSetup.cmake) -include(scripts/cmake/CompilerSetup.cmake) -include(scripts/cmake/Find.cmake) -include(scripts/cmake/CCacheSetup.cmake) -include(scripts/cmake/ProjectSetup.cmake) -include(scripts/cmake/DocumentationSetup.cmake) -include(scripts/cmake/test/Test.cmake) +include(PreFind) +include(CheckTypeSizes) +include(Functions) +include(SubmoduleSetup) +include(ConanSetup) +include(CompilerSetup) +include(Find) +include(CCacheSetup) +include(ProjectSetup) +include(DocumentationSetup) +include(test/Test) if(OGS_COVERAGE AND NOT IS_SUBPROJECT) - include(scripts/cmake/Coverage.cmake) + include(Coverage) endif() -include(scripts/cmake/Web.cmake) +include(Web) #################### ### More Options ### diff --git a/scripts/cmake/CMakeSetup.cmake b/scripts/cmake/CMakeSetup.cmake index 0a52647c69a5c7214b59224b5cfecbcc3b0e97a7..685a07e37f1dd12768e3628cbc5c1f020fa8f3a2 100644 --- a/scripts/cmake/CMakeSetup.cmake +++ b/scripts/cmake/CMakeSetup.cmake @@ -1,14 +1,23 @@ +# Disallow in-source builds as the git project cluttered with generated files +# probably confuses people. source/build* is still allowed! +if("${PROJECT_SOURCE_DIR}" STREQUAL "${PROJECT_BINARY_DIR}") + message(FATAL_ERROR "In-source builds are not allowed!\n" + "Make sure to remove CMakeCache.txt and CMakeFiles/ " + "from the source directory!") +endif() + # Set additional CMake modules path set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/scripts/cmake" "${CMAKE_CURRENT_SOURCE_DIR}/ThirdParty/cmake-modules") +list(APPEND CMAKE_PREFIX_PATH + $ENV{HOMEBREW_ROOT} # Homebrew package manager on Mac OS + $ENV{CMAKE_LIBRARY_SEARCH_PATH} # Environment variable, Windows + ${CMAKE_LIBRARY_SEARCH_PATH}) # CMake option, Windows + # Load addional modules -include(UseBackportedModules) -include(OptionRequires) -include(CppcheckTargets) include(GNUInstallDirs) - include(ProcessorCount) ProcessorCount(NUM_PROCESSORS) set(NUM_PROCESSORS ${NUM_PROCESSORS} CACHE STRING "Processor count")