diff --git a/CMakeLists.txt b/CMakeLists.txt index 4212645e4..9ce371577 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -35,17 +35,17 @@ endif() # https://docs.conan.io/en/latest/howtos/cmake_launch.html # ----------------------------------------------------------------- -if(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") +if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/conan.cmake") message( STATUS "Downloading conan.cmake from https://github.com/conan-io/cmake-conan") file( DOWNLOAD "https://raw.githubusercontent.com/conan-io/cmake-conan/master/conan.cmake" - "${CMAKE_BINARY_DIR}/conan.cmake") + "${CMAKE_CURRENT_BINARY_DIR}/conan.cmake") endif() -include(${CMAKE_BINARY_DIR}/conan.cmake) +include(${CMAKE_CURRENT_BINARY_DIR}/conan.cmake) if(${CMAKE_SYSTEM_NAME} MATCHES "Linux") # set(conan_opts ...) @@ -104,7 +104,8 @@ else() if(GIT_FOUND) execute_process( - COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_SOURCE_DIR}/.git" status + COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" + status RESULT_VARIABLE RESULT OUTPUT_QUIET ERROR_QUIET) @@ -115,20 +116,20 @@ else() if(GIT_FOUND) execute_process( - COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_SOURCE_DIR}/.git" rev-parse - HEAD + COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" + rev-parse HEAD OUTPUT_VARIABLE GIT_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( - COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_SOURCE_DIR}/.git" rev-parse - --short HEAD + COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" + rev-parse --short HEAD OUTPUT_VARIABLE GIT_COMMIT_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( - COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_SOURCE_DIR}/.git" describe - --tags + COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" + describe --tags OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -175,7 +176,7 @@ if(EXISTS ${EQUINOR_TESTDATA_ROOT}) "${EQUINOR_TESTDATA_ROOT}" "${LINK}") message(STATUS "Linking testdata: ${LINK} -> ${EQUINOR_TESTDATA_ROOT}") - set(_equinor_test_data ${CMAKE_SOURCE_DIR}/test-data/Equinor) + set(_equinor_test_data ${CMAKE_CURRENT_SOURCE_DIR}/test-data/Equinor) set(_eclpath ${_equinor_test_data}/ECLIPSE) set(_geopath ${_equinor_test_data}/Geometry) endif() @@ -355,7 +356,7 @@ test_big_endian(BIG_ENDIAN) check_type_size(time_t SIZE_OF_TIME_T) if(${SIZE_OF_TIME_T} EQUAL 8) - try_run(RUN_RESULT COMPILE_RESULT ${CMAKE_BINARY_DIR} + try_run(RUN_RESULT COMPILE_RESULT ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mktime_before1970.c) if(${COMPILE_RESULT}) if(${RUN_RESULT} EQUAL 0) @@ -364,26 +365,26 @@ if(${SIZE_OF_TIME_T} EQUAL 8) endif() endif() -try_compile(HAVE_VA_COPY ${CMAKE_BINARY_DIR} +try_compile(HAVE_VA_COPY ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_va_copy.c) -try_compile(HAVE_SIGBUS ${CMAKE_BINARY_DIR} +try_compile(HAVE_SIGBUS ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_sigbus.c) -try_compile(HAVE_PID_T ${CMAKE_BINARY_DIR} +try_compile(HAVE_PID_T ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_pid_t.c) -try_compile(HAVE_MODE_T ${CMAKE_BINARY_DIR} +try_compile(HAVE_MODE_T ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_mode_t.c) -try_compile(ERT_HAVE_ISFINITE ${CMAKE_BINARY_DIR} +try_compile(ERT_HAVE_ISFINITE ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_isfinite.c) try_compile(HAVE_SIGHANDLER_T ${PROJECT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_sighandler.c) if(ERT_HAVE_READLINKAT) - try_compile(ERT_HAVE_READLINKAT_DECLARATION ${CMAKE_BINARY_DIR} + try_compile(ERT_HAVE_READLINKAT_DECLARATION ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_have_readlinkat_decl.c) endif() set(BUILD_CXX ON) -try_compile(HAVE_CXX_SHARED_PTR ${CMAKE_BINARY_DIR} +try_compile(HAVE_CXX_SHARED_PTR ${CMAKE_CURRENT_BINARY_DIR} ${PROJECT_SOURCE_DIR}/cmake/Tests/test_shared_ptr.cpp) if(NOT HAVE_CXX_SHARED_PTR) set(BUILD_CXX OFF) @@ -399,13 +400,13 @@ find_package(Git) if(GIT_FOUND) execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( COMMAND ${GIT_EXECUTABLE} rev-parse --short HEAD - WORKING_DIRECTORY ${CMAKE_SOURCE_DIR} + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} OUTPUT_VARIABLE GIT_COMMIT_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE) else()