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 /src | |
| 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)
Diffstat (limited to 'src')
| -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 |
5 files changed, 73 insertions, 3 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}) |
