From 609fb5948d862f67af6c9521efa812c39612aef4 Mon Sep 17 00:00:00 2001 From: "Cheng, Xiaoxing" <0001001bill@gmail.com> Date: Sun, 2 Oct 2022 23:09:30 -0500 Subject: [PATCH 1/4] Update CMakeLists.txt Use CMAKE_CURRENT_SOURCE_DIR when looking for tag, this will prevent potential problems if the project is grabbed by fetchContent in other project --- CMakeLists.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c161d879..f64323aba 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -126,7 +126,7 @@ else() OUTPUT_STRIP_TRAILING_WHITESPACE) execute_process( - COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_SOURCE_DIR}/.git" describe + COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" describe --tags OUTPUT_VARIABLE GIT_TAG OUTPUT_STRIP_TRAILING_WHITESPACE) From dc580ee4e070c2b862e981ba298f77dbefde56c1 Mon Sep 17 00:00:00 2001 From: chengxiaoxing <0001001bill@gmail.com> Date: Tue, 17 Jan 2023 10:49:15 -0500 Subject: [PATCH 2/4] change all cmake_source_dir to cmake_current_source_dir --- CMakeLists.txt | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d478eec9d..b2a0cd1b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,7 @@ 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,13 +115,13 @@ else() if(GIT_FOUND) execute_process( - COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_SOURCE_DIR}/.git" rev-parse + 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 + COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_SOURCE_DIR}/.git" rev-parse --short HEAD OUTPUT_VARIABLE GIT_COMMIT_SHORT OUTPUT_STRIP_TRAILING_WHITESPACE) @@ -175,7 +175,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() @@ -399,13 +399,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() From f5cde4f3dc825d9fb55a8252c7f9403ca50278f9 Mon Sep 17 00:00:00 2001 From: chengxiaoxing <0001001bill@gmail.com> Date: Tue, 17 Jan 2023 10:50:55 -0500 Subject: [PATCH 3/4] change all cmake_binary_dir to cmake_current_binary_dir --- CMakeLists.txt | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index b2a0cd1b2..0cf8a70ed 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 ...) @@ -355,7 +355,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 +364,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) From 15645db6b645d2ab07a64de9b2c4579267e2e580 Mon Sep 17 00:00:00 2001 From: chengxiaoxing <0001001bill@gmail.com> Date: Tue, 17 Jan 2023 11:00:02 -0500 Subject: [PATCH 4/4] run cmake-format on CMakeLists.txt --- CMakeLists.txt | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 0cf8a70ed..9ce371577 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -104,7 +104,8 @@ else() if(GIT_FOUND) execute_process( - COMMAND ${GIT_EXECUTABLE} "--git-dir=${CMAKE_CURRENT_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_CURRENT_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_CURRENT_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_CURRENT_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)