diff options
| author | Mike Taves <mwtoews@gmail.com> | 2020-03-28 12:44:30 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2020-03-28 12:44:30 +1300 |
| commit | 54fdb90a204a39342bfcbab197e3b5da47a9f1cd (patch) | |
| tree | d4d8189638c263b3f203db15579a820c9eef214a /test/unit/CMakeLists.txt | |
| parent | 238f48fb7cd006296cbd622ab9e4187139af9a8e (diff) | |
| download | PROJ-54fdb90a204a39342bfcbab197e3b5da47a9f1cd.tar.gz PROJ-54fdb90a204a39342bfcbab197e3b5da47a9f1cd.zip | |
CMake: prefer to use use PROJ_SOURCE_DIR and PROJ_BINARY_DIR (#2100)
* Use instead of CMAKE_SOURCE_DIR and CMAKE_BINARY_DIR
* Also PROJECT_SOURCE_DIR and PROJECT_BINARY_DIR, which are similar
* Set properties with a list variable rather than a long line
* Correction to 'proj_test_set_properties' function, rename ENVIRONMENT:
- PROJ_IGNORE_USER_WRITABLE_DIRECTORY (ignored)
- PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY (used by filemanager.cpp)
Diffstat (limited to 'test/unit/CMakeLists.txt')
| -rw-r--r-- | test/unit/CMakeLists.txt | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/test/unit/CMakeLists.txt b/test/unit/CMakeLists.txt index 398738ad..62932aae 100644 --- a/test/unit/CMakeLists.txt +++ b/test/unit/CMakeLists.txt @@ -17,17 +17,17 @@ message(STATUS "Using internal GTest") # Source https://github.com/google/googletest/blob/master/googletest/README.md # Download and unpack googletest at configure time configure_file( - ${CMAKE_SOURCE_DIR}/test/googletest/CMakeLists.txt.in - ${CMAKE_BINARY_DIR}/googletest-download/CMakeLists.txt) + ${PROJ_SOURCE_DIR}/test/googletest/CMakeLists.txt.in + ${PROJ_BINARY_DIR}/googletest-download/CMakeLists.txt) execute_process(COMMAND ${CMAKE_COMMAND} -G "${CMAKE_GENERATOR}" . RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) + WORKING_DIRECTORY ${PROJ_BINARY_DIR}/googletest-download) if(result) message(FATAL_ERROR "CMake step for googletest failed: ${result}") endif() execute_process(COMMAND ${CMAKE_COMMAND} --build . RESULT_VARIABLE result - WORKING_DIRECTORY ${CMAKE_BINARY_DIR}/googletest-download) + WORKING_DIRECTORY ${PROJ_BINARY_DIR}/googletest-download) if(result) message(FATAL_ERROR "Build step for googletest failed: ${result}") endif() @@ -38,8 +38,8 @@ set(gtest_force_shared_crt ON CACHE BOOL "" FORCE) # the gtest and gtest_main targets. option(INSTALL_GTEST "Enable installation of googletest" OFF) add_subdirectory( - ${CMAKE_BINARY_DIR}/googletest-src - ${CMAKE_BINARY_DIR}/googletest-build + ${PROJ_BINARY_DIR}/googletest-src + ${PROJ_BINARY_DIR}/googletest-build EXCLUDE_FROM_ALL) # Provide the same target name as find_package(GTest) @@ -55,14 +55,20 @@ if(MSVC AND BUILD_SHARED_LIBS) add_definitions(-DPROJ_MSVC_DLL_IMPORT=1) endif() -include_directories(${CMAKE_SOURCE_DIR}/include) +include_directories(${PROJ_SOURCE_DIR}/include) include_directories(${SQLITE3_INCLUDE_DIR}) # Add the directory containing proj_config.h -include_directories(${CMAKE_BINARY_DIR}/src) +include_directories(${PROJ_BINARY_DIR}/src) # Apply to targets in the current directory and below add_compile_options(${PROJ_CXX_WARN_FLAGS}) +set(PROJ_TEST_ENVIRONMENT + "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES" + "PROJ_LIB=${PROJ_BINARY_DIR}/data/for_tests" + "PROJ_SOURCE_DATA=${PROJ_SOURCE_DIR}/data" +) + add_executable(proj_pj_transform_test main.cpp pj_transform_test.cpp) @@ -71,7 +77,7 @@ target_link_libraries(proj_pj_transform_test ${PROJ_LIBRARIES}) add_test(NAME proj_pj_transform_test COMMAND proj_pj_transform_test) set_property(TEST proj_pj_transform_test - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests") + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) add_executable(proj_errno_string_test @@ -82,7 +88,7 @@ target_link_libraries(proj_errno_string_test ${PROJ_LIBRARIES}) add_test(NAME proj_errno_string_test COMMAND proj_errno_string_test) set_property(TEST proj_errno_string_test - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests") + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) add_executable(proj_angular_io_test main.cpp @@ -92,7 +98,7 @@ target_link_libraries(proj_angular_io_test ${PROJ_LIBRARIES}) add_test(NAME proj_angular_io_test COMMAND proj_angular_io_test) set_property(TEST proj_angular_io_test - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests") + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) add_executable(proj_context_test main.cpp @@ -102,7 +108,7 @@ target_link_libraries(proj_context_test ${PROJ_LIBRARIES}) add_test(NAME proj_context_test COMMAND proj_context_test) set_property(TEST proj_context_test - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests") + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) if(MSVC AND BUILD_SHARED_LIBS) # ph_phi2_test not compatible of a .dll build @@ -115,7 +121,7 @@ else() ${PROJ_LIBRARIES}) add_test(NAME pj_phi2_test COMMAND pj_phi2_test) set_property(TEST pj_phi2_test - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests") + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) endif() add_executable(proj_test_cpp_api @@ -136,7 +142,7 @@ target_link_libraries(proj_test_cpp_api ${SQLITE3_LIBRARY}) add_test(NAME proj_test_cpp_api COMMAND proj_test_cpp_api) set_property(TEST proj_test_cpp_api - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests") + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) add_executable(gie_self_tests @@ -147,8 +153,7 @@ target_link_libraries(gie_self_tests ${PROJ_LIBRARIES}) add_test(NAME gie_self_tests COMMAND gie_self_tests) set_property(TEST gie_self_tests - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests") - + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) add_executable(test_network main.cpp @@ -164,4 +169,4 @@ target_link_libraries(test_network ${SQLITE3_LIBRARY}) add_test(NAME test_network COMMAND test_network) set_property(TEST test_network - PROPERTY ENVIRONMENT "PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES;PROJ_LIB=${PROJECT_BINARY_DIR}/data/for_tests;PROJ_SOURCE_DATA=${PROJECT_SOURCE_DIR}/data") + PROPERTY ENVIRONMENT ${PROJ_TEST_ENVIRONMENT}) |
