From 5a7ea55f0d833bab220143f417c19866cfdc49e2 Mon Sep 17 00:00:00 2001 From: Lars Bilke <lars.bilke@ufz.de> Date: Tue, 18 Sep 2018 11:41:57 +0200 Subject: [PATCH] [CMake] Re-ordered CMakeSetup.cmake a bit. --- CMakeLists.txt | 32 ++++++++++++++------------------ scripts/cmake/CMakeSetup.cmake | 17 +++++++++++++---- 2 files changed, 27 insertions(+), 22 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 39e3716c5d0..6a889ee6fd5 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 0a52647c69a..685a07e37f1 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") -- GitLab