diff options
| author | Even Rouault <even.rouault@spatialys.com> | 2021-10-12 10:03:27 +0200 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-12 10:03:27 +0200 |
| commit | 6a877010114b7ccc12d017989500fa5f12f9e39c (patch) | |
| tree | c257d0e1296c2c6a874c750a0139983d6d3e41b3 | |
| parent | a16ead184573933b128e419253c69418212df495 (diff) | |
| parent | a159c44f35e58334646d3c8653acc86665c55cca (diff) | |
| download | PROJ-6a877010114b7ccc12d017989500fa5f12f9e39c.tar.gz PROJ-6a877010114b7ccc12d017989500fa5f12f9e39c.zip | |
Merge pull request #2897 from rouault/fix_2852
CMake build: generate invproj/invgeod binaries (symlinks on Unix, copy otherwise) (fixes #2852)
| -rw-r--r-- | src/Makefile.am | 6 | ||||
| -rw-r--r-- | src/apps/geod.cpp | 3 | ||||
| -rw-r--r-- | src/apps/proj.cpp | 3 | ||||
| -rw-r--r-- | src/bin_geod.cmake | 32 | ||||
| -rw-r--r-- | src/bin_proj.cmake | 32 | ||||
| -rw-r--r-- | test/cli/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | test/cli/Makefile.am | 8 | ||||
| -rwxr-xr-x | test/cli/testinvproj | 55 | ||||
| -rw-r--r-- | test/cli/testinvproj_out.dist | 1 | ||||
| -rwxr-xr-x | test/cli/testproj | 2 |
10 files changed, 139 insertions, 5 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 0723d942..1e847080 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -25,10 +25,12 @@ EXTRA_DIST = bin_cct.cmake bin_gie.cmake bin_cs2cs.cmake \ apps/projsync.cpp proj_SOURCES = apps/proj.cpp apps/emess.cpp apps/utils.cpp +invproj_SOURCES = $(proj_SOURCES) projinfo_SOURCES = apps/projinfo.cpp cs2cs_SOURCES = apps/cs2cs.cpp apps/emess.cpp apps/utils.cpp cct_SOURCES = apps/cct.cpp apps/proj_strtod.cpp apps/proj_strtod.h apps/optargpm.h geod_SOURCES = apps/geod.cpp apps/geod_set.cpp apps/geod_interface.cpp apps/geod_interface.h apps/emess.cpp +invgeod_SOURCES = $(geod_SOURCES) if HAVE_CURL projsync_SOURCES = apps/projsync.cpp @@ -37,6 +39,7 @@ PROJSYNC_BIN = projsync endif bin_PROGRAMS = proj geod cs2cs gie cct projinfo $(PROJSYNC_BIN) +noinst_PROGRAMS = invproj invgeod gie_SOURCES = apps/gie.cpp apps/proj_strtod.cpp apps/proj_strtod.h apps/optargpm.h multistresstest_SOURCES = tests/multistresstest.cpp @@ -45,7 +48,9 @@ geodtest_SOURCES = tests/geodtest.cpp cct_LDADD = libproj.la cs2cs_LDADD = libproj.la geod_LDADD = libproj.la +invgeod_LDADD = $(geod_LDADD) proj_LDADD = libproj.la +invproj_LDADD = $(proj_LDADD) projinfo_LDADD = libproj.la gie_LDADD = libproj.la @@ -276,7 +281,6 @@ wkt2_parser: sed "s/\*yyssp = yystate/\*yyssp = (yytype_int16)yystate/" < $(top_srcdir)/src/wkt2_generated_parser.c | sed "s/yyerrorlab:/#if 0\nyyerrorlab:/" | sed "s/yyerrlab1:/#endif\nyyerrlab1:/" | sed "s/for (yylen = 0; yystr\[yylen\]; yylen++)/for (yylen = 0; yystr \&\& yystr\[yylen\]; yylen++)/"| sed "s/return yystpcpy (yyres, yystr) - yyres;/return (YYPTRDIFF_T)(yystpcpy (yyres, yystr) - yyres);/" | sed "s/YYPTRDIFF_T yysize = yyssp - yyss + 1;/YYPTRDIFF_T yysize = (YYPTRDIFF_T)(yyssp - yyss + 1);/"> $(top_srcdir)/src/wkt2_generated_parser.c.tmp mv $(top_srcdir)/src/wkt2_generated_parser.c.tmp $(top_srcdir)/src/wkt2_generated_parser.c - install-exec-local: install-binPROGRAMS rm -f $(DESTDIR)$(bindir)/invproj$(EXEEXT) (cd $(DESTDIR)$(bindir); ln -s proj$(EXEEXT) invproj$(EXEEXT)) diff --git a/src/apps/geod.cpp b/src/apps/geod.cpp index 35a8e826..6e3f059e 100644 --- a/src/apps/geod.cpp +++ b/src/apps/geod.cpp @@ -138,7 +138,8 @@ int main(int argc, char **argv) { if ((emess_dat.Prog_name = strrchr(*argv,'/')) != nullptr) ++emess_dat.Prog_name; else emess_dat.Prog_name = *argv; - inverse = ! strncmp(emess_dat.Prog_name, "inv", 3); + inverse = strncmp(emess_dat.Prog_name, "inv", 3) == 0 || + strncmp(emess_dat.Prog_name, "lt-inv", 6) == 0; // older libtool have a lt- prefix if (argc <= 1 ) { (void)fprintf(stderr, usage, pj_get_release(), emess_dat.Prog_name); diff --git a/src/apps/proj.cpp b/src/apps/proj.cpp index 6368ef2c..f93164e0 100644 --- a/src/apps/proj.cpp +++ b/src/apps/proj.cpp @@ -303,7 +303,8 @@ int main(int argc, char **argv) { if ( (emess_dat.Prog_name = strrchr(*argv,DIR_CHAR)) != nullptr) ++emess_dat.Prog_name; else emess_dat.Prog_name = *argv; - inverse = ! strncmp(emess_dat.Prog_name, "inv", 3); + inverse = strncmp(emess_dat.Prog_name, "inv", 3) == 0 || + strncmp(emess_dat.Prog_name, "lt-inv", 6) == 0; // older libtool have a lt- prefix if (argc <= 1 ) { (void)fprintf(stderr, usage, pj_get_release(), emess_dat.Prog_name); exit (0); diff --git a/src/bin_geod.cmake b/src/bin_geod.cmake index 4ec28b04..4d91628a 100644 --- a/src/bin_geod.cmake +++ b/src/bin_geod.cmake @@ -18,3 +18,35 @@ install(TARGETS geod if(MSVC AND BUILD_SHARED_LIBS) target_compile_definitions(geod PRIVATE PROJ_MSVC_DLL_IMPORT=1) endif() + +# invgeod target: symlink or copy of geod executable + +set(link_target "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/invgeod${CMAKE_EXECUTABLE_SUFFIX}") +set(link_source "geod${CMAKE_EXECUTABLE_SUFFIX}") + +if(UNIX) + 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 + ) +else() + # symlinks are supported on Windows in cmake >= 3.17, but + # symlinks on Windows are a bit tricky, so just copy + + add_custom_command( + OUTPUT ${link_target} + COMMAND ${CMAKE_COMMAND} -E copy ${link_source} ${link_target} + WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + DEPENDS geod + COMMENT "Generating invgeod" + VERBATIM + ) +endif() + +add_custom_target(invgeod ALL DEPENDS ${link_target}) + +install(FILES ${link_target} DESTINATION ${BINDIR}) diff --git a/src/bin_proj.cmake b/src/bin_proj.cmake index b5a4c140..2976b3da 100644 --- a/src/bin_proj.cmake +++ b/src/bin_proj.cmake @@ -19,3 +19,35 @@ install(TARGETS binproj if(MSVC AND BUILD_SHARED_LIBS) target_compile_definitions(binproj PRIVATE PROJ_MSVC_DLL_IMPORT=1) endif() + +# invproj target: symlink or copy of proj executable + +set(link_target "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/invproj${CMAKE_EXECUTABLE_SUFFIX}") +set(link_source "proj${CMAKE_EXECUTABLE_SUFFIX}") + +if(UNIX) + 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 + ) +else() + # symlinks are supported on Windows in cmake >= 3.17, but + # symlinks on Windows are a bit tricky, so just copy + + add_custom_command( + OUTPUT ${link_target} + COMMAND ${CMAKE_COMMAND} -E copy ${link_source} ${link_target} + WORKING_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}" + DEPENDS binproj + COMMENT "Generating invproj" + VERBATIM + ) +endif() + +add_custom_target(invproj ALL DEPENDS ${link_target}) + +install(FILES ${link_target} DESTINATION ${BINDIR}) diff --git a/test/cli/CMakeLists.txt b/test/cli/CMakeLists.txt index 0f86ca3d..b136b05d 100644 --- a/test/cli/CMakeLists.txt +++ b/test/cli/CMakeLists.txt @@ -3,12 +3,14 @@ # set(CS2CS_BIN "cs2cs") set(PROJ_BIN "proj") +set(INVPROJ_BIN "invproj") set(PROJINFO_BIN "projinfo") set(CCT_BIN "cct") set(PROJSYNC_BIN "projsync") proj_add_test_script_sh("test27" PROJ_BIN) proj_add_test_script_sh("test83" PROJ_BIN) proj_add_test_script_sh("testproj" PROJ_BIN) +proj_add_test_script_sh("testinvproj" INVPROJ_BIN) proj_add_test_script_sh("testvarious" CS2CS_BIN) proj_add_test_script_sh("testdatumfile" CS2CS_BIN) proj_add_test_script_sh("testIGNF" CS2CS_BIN) diff --git a/test/cli/Makefile.am b/test/cli/Makefile.am index 46d9d36c..bc840738 100644 --- a/test/cli/Makefile.am +++ b/test/cli/Makefile.am @@ -3,6 +3,7 @@ PROJ_LIB = ../../data/for_tests THIS_DIR = $(top_srcdir)/test/cli EXEPATH = ../../src PROJEXE = $(EXEPATH)/proj +INVPROJEXE = $(EXEPATH)/invproj CS2CSEXE = $(EXEPATH)/cs2cs PROJINFOEXE = $(EXEPATH)/projinfo CCTEXE = $(EXEPATH)/cct @@ -12,6 +13,7 @@ PROJSYNC_EXE = $(EXEPATH)/projsync TEST27 = $(THIS_DIR)/test27 TEST83 = $(THIS_DIR)/test83 TESTPROJ = $(THIS_DIR)/testproj +TESTINVPROJ = $(THIS_DIR)/testinvproj TESTNTV2 = $(THIS_DIR)/testntv2 TESTVARIOUS = $(THIS_DIR)/testvarious TESTFLAKY = $(THIS_DIR)/testflaky @@ -28,6 +30,7 @@ EXTRA_DIST = pj_out27.dist pj_out83.dist td_out.dist \ testprojinfo testprojinfo_out.dist \ testcct testcct_out.dist \ testproj testproj_out.dist \ + testinvproj testinvproj_out.dist \ test_projsync \ CMakeLists.txt @@ -43,6 +46,9 @@ test83-check: testproj-check: PROJ_LIB=$(PROJ_LIB) $(TESTPROJ) $(PROJEXE) +testinvproj-check: + PROJ_LIB=$(PROJ_LIB) $(TESTINVPROJ) $(INVPROJEXE) + testvarious-check: PROJ_SKIP_READ_USER_WRITABLE_DIRECTORY=YES PROJ_LIB=$(PROJ_LIB) $(TESTVARIOUS) $(CS2CSEXE) @@ -67,4 +73,4 @@ testprojsync-check: echo "Skipping testprojsync-check" endif -check-local: testprojinfo-check test27-check test83-check testproj-check testvarious-check testdatumfile-check testign-check testntv2-check testcct-check testprojsync-check +check-local: testprojinfo-check test27-check test83-check testproj-check testinvproj-check testvarious-check testdatumfile-check testign-check testntv2-check testcct-check testprojsync-check diff --git a/test/cli/testinvproj b/test/cli/testinvproj new file mode 100755 index 00000000..878fd118 --- /dev/null +++ b/test/cli/testinvproj @@ -0,0 +1,55 @@ +: +# Script to test invproj exe +# +TEST_CLI_DIR=`dirname $0` +EXE=$1 + +usage() +{ + echo "Usage: ${0} <path to 'invproj' program>" + echo + exit 1 +} + +if test -z "${EXE}"; then + EXE=../../src/invproj +fi + +if test ! -x ${EXE}; then + echo "*** ERROR: Can not find '${EXE}' program!" + exit 1 +fi + +if test -z "${PROJ_LIB}"; then + export PROJ_LIB="`dirname $0`/../../data" +fi + +echo "============================================" +echo "Running ${0} using ${EXE}:" +echo "============================================" + +OUT=testinvproj_out +# +echo "doing tests into file ${OUT}, please wait" +# +$EXE +proj=tmerc +ellps=GRS80 -E -f '%.3f' >${OUT} <<EOF +146339.48 5431555.61 +EOF + +# +# do 'diff' with distribution results +echo "diff ${OUT} with testinvproj_out.dist" +diff -u -b ${OUT} ${TEST_CLI_DIR}/testinvproj_out.dist +if [ $? -ne 0 ] ; then + echo "" + echo "PROBLEMS HAVE OCCURRED" + echo "test file ${OUT} saved" + echo + exit 100 +else + echo "TEST OK" + echo "test file ${OUT} removed" + echo + /bin/rm -f ${OUT} + exit 0 +fi diff --git a/test/cli/testinvproj_out.dist b/test/cli/testinvproj_out.dist new file mode 100644 index 00000000..6b52306f --- /dev/null +++ b/test/cli/testinvproj_out.dist @@ -0,0 +1 @@ +146339.48 5431555.61 2.000 49.000 diff --git a/test/cli/testproj b/test/cli/testproj index 8686224e..d03932fb 100755 --- a/test/cli/testproj +++ b/test/cli/testproj @@ -12,7 +12,7 @@ usage() } if test -z "${EXE}"; then - EXE=../../src/cs2cs + EXE=../../src/proj fi if test ! -x ${EXE}; then |
