diff options
| author | Mike Taves <mwtoews@gmail.com> | 2022-02-14 22:07:34 +1300 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-02-14 22:07:34 +1300 |
| commit | cb35cb17ace5d16c63d700378d78e0b057531e25 (patch) | |
| tree | 22effa82d30e6fb10d655b832065eeb8086b9015 /src/apps | |
| parent | 6bc988593357c2c5d47e98db6ee7e2a394113052 (diff) | |
| download | PROJ-cb35cb17ace5d16c63d700378d78e0b057531e25.tar.gz PROJ-cb35cb17ace5d16c63d700378d78e0b057531e25.zip | |
CMake: split configuration files for apps and tests (#3048)
Diffstat (limited to 'src/apps')
| -rw-r--r-- | src/apps/CMakeLists.txt | 94 | ||||
| -rw-r--r-- | src/apps/bin_cct.cmake | 14 | ||||
| -rw-r--r-- | src/apps/bin_cs2cs.cmake | 13 | ||||
| -rw-r--r-- | src/apps/bin_geod.cmake | 45 | ||||
| -rw-r--r-- | src/apps/bin_gie.cmake | 16 | ||||
| -rw-r--r-- | src/apps/bin_proj.cmake | 46 | ||||
| -rw-r--r-- | src/apps/bin_projinfo.cmake | 13 | ||||
| -rw-r--r-- | src/apps/bin_projsync.cmake | 9 |
8 files changed, 250 insertions, 0 deletions
diff --git a/src/apps/CMakeLists.txt b/src/apps/CMakeLists.txt new file mode 100644 index 00000000..0f16ef91 --- /dev/null +++ b/src/apps/CMakeLists.txt @@ -0,0 +1,94 @@ +# Configure executable builds +option(BUILD_APPS + "Build PROJ applications (default value for BUILD_CCT, BUILD_CS2CS, etc.)" + ON) + +option(BUILD_CCT + "Build cct (coordinate conversion and transformation tool)" + "${BUILD_APPS}") +option(BUILD_CS2CS + "Build cs2cs (coordinate systems to coordinate systems translation tool)" + "${BUILD_APPS}") +option(BUILD_GEOD + "Build geod (computation of geodesic lines)" + "${BUILD_APPS}") +option(BUILD_GIE + "Build gie (geospatial integrity investigation environment)" + "${BUILD_APPS}") +option(BUILD_PROJ + "Build proj (cartographic projection tool)" + "${BUILD_APPS}") +option(BUILD_PROJINFO + "Build projinfo (SRS and coordinate operation metadata/query tool)" + "${BUILD_APPS}") +option(BUILD_PROJSYNC + "Build projsync (synchronize transformation support data)" + "${BUILD_APPS}") + +if(NOT MSVC) + + # Use relative path so that package is relocatable + if(APPLE) + set(CMAKE_INSTALL_RPATH "@loader_path/../${LIBDIR}") + else() + set(CMAKE_INSTALL_RPATH "\$ORIGIN/../${LIBDIR}") + endif() + # Other apps can link to libproj using e.g. LDFLAGS -Wl,-rpath,${prefix}/lib + +else() + + # Linking to setargv.obj enables wildcard globbing for the + # command line utilities, when compiling with MSVC + # https://docs.microsoft.com/cpp/c-language/expanding-wildcard-arguments + set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} setargv.obj") + +endif() + +if(BUILD_CCT) + include(bin_cct.cmake) + list(APPEND BIN_TARGETS cct) +endif() + +if(BUILD_CS2CS) + include(bin_cs2cs.cmake) + list(APPEND BIN_TARGETS cs2cs) +endif() + +if(BUILD_GEOD) + include(bin_geod.cmake) + list(APPEND BIN_TARGETS geod) +endif() + +if(BUILD_PROJ) + include(bin_proj.cmake) + list(APPEND BIN_TARGETS binproj) +endif() + +if(BUILD_PROJINFO) + include(bin_projinfo.cmake) + list(APPEND BIN_TARGETS projinfo) +endif() + +# Always build gie if testing is requested +if(BUILD_GIE OR BUILD_TESTING) + include(bin_gie.cmake) + list(APPEND BIN_TARGETS gie) +endif() + +if(BUILD_PROJSYNC) + if(NOT ENABLE_CURL) + message(SEND_ERROR "projsync requires Curl") + endif() + include(bin_projsync.cmake) + list(APPEND BIN_TARGETS projsync) +endif() + +# global configurations for all apps + +if(MSVC OR CMAKE_CONFIGURATION_TYPES) + if(BIN_TARGETS) + # Add _d suffix for debug versions of the apps + set_target_properties(${BIN_TARGETS} PROPERTIES + DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX}) + endif() +endif() diff --git a/src/apps/bin_cct.cmake b/src/apps/bin_cct.cmake new file mode 100644 index 00000000..94b0f878 --- /dev/null +++ b/src/apps/bin_cct.cmake @@ -0,0 +1,14 @@ +set(CCT_SRC + cct.cpp + proj_strtod.cpp + proj_strtod.h +) +set(CCT_INCLUDE optargpm.h) + +source_group("Source Files\\Bin" FILES ${CCT_SRC}) + +add_executable(cct ${CCT_SRC} ${CCT_INCLUDE}) +target_link_libraries(cct PRIVATE ${PROJ_LIBRARIES}) + +install(TARGETS cct + DESTINATION ${BINDIR}) diff --git a/src/apps/bin_cs2cs.cmake b/src/apps/bin_cs2cs.cmake new file mode 100644 index 00000000..c5e82478 --- /dev/null +++ b/src/apps/bin_cs2cs.cmake @@ -0,0 +1,13 @@ +set(CS2CS_SRC + cs2cs.cpp + emess.cpp + utils.cpp +) + +source_group("Source Files\\Bin" FILES ${CS2CS_SRC}) + +add_executable(cs2cs ${CS2CS_SRC} ${CS2CS_INCLUDE}) +target_link_libraries(cs2cs PRIVATE ${PROJ_LIBRARIES}) + +install(TARGETS cs2cs + DESTINATION ${BINDIR}) diff --git a/src/apps/bin_geod.cmake b/src/apps/bin_geod.cmake new file mode 100644 index 00000000..4fa41977 --- /dev/null +++ b/src/apps/bin_geod.cmake @@ -0,0 +1,45 @@ +set(GEOD_SRC + geod.cpp + geod_set.cpp + geod_interface.cpp + emess.cpp +) +set(GEOD_INCLUDE geod_interface.h) + +source_group("Source Files\\Bin" FILES ${GEOD_SRC} ${GEOD_INCLUDE}) + +add_executable(geod ${GEOD_SRC} ${GEOD_INCLUDE}) +target_link_libraries(geod PRIVATE ${PROJ_LIBRARIES}) + +install(TARGETS geod + DESTINATION ${BINDIR}) + +# invgeod target: symlink or copy of geod executable + +if(UNIX) + + set(link_target "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/invgeod${CMAKE_EXECUTABLE_SUFFIX}") + set(link_source "geod${CMAKE_EXECUTABLE_SUFFIX}") + + add_custom_command( + OUTPUT ${link_target} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${link_source} ${link_target} + WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + DEPENDS geod + COMMENT "Generating invgeod" + VERBATIM + ) + + add_custom_target(invgeod ALL DEPENDS ${link_target}) + + install(FILES ${link_target} DESTINATION ${BINDIR}) + +else() + + add_executable(invgeod ${GEOD_SRC} ${GEOD_INCLUDE}) + target_link_libraries(invgeod PRIVATE ${PROJ_LIBRARIES}) + + install(TARGETS invgeod + DESTINATION ${BINDIR}) + +endif() diff --git a/src/apps/bin_gie.cmake b/src/apps/bin_gie.cmake new file mode 100644 index 00000000..8e2d2278 --- /dev/null +++ b/src/apps/bin_gie.cmake @@ -0,0 +1,16 @@ +set(GIE_SRC + gie.cpp + proj_strtod.cpp + proj_strtod.h +) +set(GIE_INCLUDE optargpm.h) + +source_group("Source Files\\Bin" FILES ${GIE_SRC}) + +add_executable(gie ${GIE_SRC} ${GIE_INCLUDE}) +target_link_libraries(gie PRIVATE ${PROJ_LIBRARIES}) + +if(BUILD_GIE) + install(TARGETS gie + DESTINATION ${BINDIR}) +endif() diff --git a/src/apps/bin_proj.cmake b/src/apps/bin_proj.cmake new file mode 100644 index 00000000..86232f59 --- /dev/null +++ b/src/apps/bin_proj.cmake @@ -0,0 +1,46 @@ +set(PROJ_SRC + proj.cpp + emess.cpp + utils.cpp +) + +source_group("Source Files\\Bin" FILES ${PROJ_SRC}) + +add_executable(binproj ${PROJ_SRC}) +set_target_properties(binproj + PROPERTIES + RUNTIME_OUTPUT_NAME proj) +target_link_libraries(binproj PRIVATE ${PROJ_LIBRARIES}) + +install(TARGETS binproj + DESTINATION ${BINDIR}) + +# invproj target: symlink or copy of proj executable + +if(UNIX) + + set(link_target "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/invproj${CMAKE_EXECUTABLE_SUFFIX}") + set(link_source "proj${CMAKE_EXECUTABLE_SUFFIX}") + + add_custom_command( + OUTPUT ${link_target} + COMMAND ${CMAKE_COMMAND} -E create_symlink ${link_source} ${link_target} + WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + DEPENDS binproj + COMMENT "Generating invproj" + VERBATIM + ) + + add_custom_target(invproj ALL DEPENDS ${link_target}) + + install(FILES ${link_target} DESTINATION ${BINDIR}) + +else() + + add_executable(invproj ${PROJ_SRC}) + target_link_libraries(invproj PRIVATE ${PROJ_LIBRARIES}) + + install(TARGETS invproj + DESTINATION ${BINDIR}) + +endif() diff --git a/src/apps/bin_projinfo.cmake b/src/apps/bin_projinfo.cmake new file mode 100644 index 00000000..e5b03424 --- /dev/null +++ b/src/apps/bin_projinfo.cmake @@ -0,0 +1,13 @@ +set(PROJINFO_SRC projinfo.cpp) + +source_group("Source Files\\Bin" FILES ${PROJINFO_SRC}) + +add_executable(projinfo ${PROJINFO_SRC}) +target_link_libraries(projinfo PRIVATE ${PROJ_LIBRARIES}) + +install(TARGETS projinfo + DESTINATION ${BINDIR}) + +if(CURL_ENABLED) + target_compile_definitions(projinfo PRIVATE -DCURL_ENABLED) +endif() diff --git a/src/apps/bin_projsync.cmake b/src/apps/bin_projsync.cmake new file mode 100644 index 00000000..c51d28da --- /dev/null +++ b/src/apps/bin_projsync.cmake @@ -0,0 +1,9 @@ +set(PROJSYNC_SRC projsync.cpp) + +source_group("Source Files\\Bin" FILES ${PROJSYNC_SRC}) + +add_executable(projsync ${PROJSYNC_SRC}) +target_link_libraries(projsync PRIVATE ${PROJ_LIBRARIES}) + +install(TARGETS projsync + DESTINATION ${BINDIR}) |
