cmake: Add program prefix option. (#2515)
authorMathias Preiner <mathias.preiner@gmail.com>
Mon, 24 Sep 2018 18:44:41 +0000 (11:44 -0700)
committerGitHub <noreply@github.com>
Mon, 24 Sep 2018 18:44:41 +0000 (11:44 -0700)
CMakeLists.txt
configure.sh
src/main/CMakeLists.txt

index b097a70d7bd59dc1d4ae1eee5d26c59af59d9610..453f1bcf73e18fb44f4deed97cfa38c17e5015a5 100644 (file)
@@ -95,6 +95,9 @@ set(GMP_DIR           "" CACHE STRING "Set GMP install directory")
 set(LFSC_DIR          "" CACHE STRING "Set LFSC install directory")
 set(SYMFPU_DIR        "" CACHE STRING "Set SymFPU install directory")
 
+# Prepend binaries with prefix on make install
+set(PROGRAM_PREFIX    "" CACHE STRING "Program prefix on make install")
+
 # Supported language bindings
 option(BUILD_BINDINGS_JAVA   "Build Java bindings")
 option(BUILD_BINDINGS_PYTHON "Build Python bindings")
index b92c48ad47f7642d567ddba9ff8448e0418fddb8..16764dd8ab1a35efa9838a743262223b060a694d 100755 (executable)
@@ -15,6 +15,7 @@ Build types:
 General options;
   -h, --help               display this help and exit
   --prefix=STR             install directory
+  --program-prefix=STR     prefix of binaries prepended on make install
   --name=STR               use custom build directory name (optionally: +path)
   --best                   turn on dependencies known to give best performance
   --gpl                    permit GPL dependencies, if available
@@ -95,6 +96,7 @@ msg () {
 
 build_dir=build
 install_prefix=default
+program_prefix=""
 
 #--------------------------------------------------------------------------#
 
@@ -174,6 +176,9 @@ do
         esac
         ;;
 
+    --program-prefix) die "missing argument to $1 (try -h)" ;;
+    --program-prefix=*) program_prefix=${1##*=} ;;
+
     --name) die "missing argument to $1 (try -h)" ;;
     --name=*) build_dir=${1##*=} ;;
 
@@ -401,6 +406,8 @@ cmake_opts=""
   && cmake_opts="$cmake_opts -DSYMFPU_DIR=$symfpu_dir"
 [ "$install_prefix" != default ] \
   && cmake_opts="$cmake_opts -DCMAKE_INSTALL_PREFIX=$install_prefix"
+[ -n "$program_prefix" ] \
+  && cmake_opts="$cmake_opts -DPROGRAM_PREFIX=$program_prefix"
 
 root_dir=$(pwd)
 
index 30a246ba006dbf7c135a5c24a0df6262e05f3eb3..dba12006e067d30a6f6ed62bcb33b1c177d22e7b 100644 (file)
@@ -45,7 +45,12 @@ set_target_properties(cvc4-bin
     OUTPUT_NAME cvc4
     RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
 target_link_libraries(cvc4-bin cvc4 cvc4parser)
-install(TARGETS cvc4-bin DESTINATION bin)
+if(PROGRAM_PREFIX)
+  install(PROGRAMS
+    $<TARGET_FILE:cvc4-bin> DESTINATION bin RENAME ${PROGRAM_PREFIX}cvc4)
+else()
+  install(TARGETS cvc4-bin DESTINATION bin)
+endif()
 
 # In order to get a fully static executable we have to make sure that we also
 # use the static system libraries.
@@ -76,7 +81,12 @@ if(ENABLE_PORTFOLIO)
       RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
   target_link_libraries(pcvc4-bin cvc4 cvc4parser ${Boost_LIBRARIES})
   target_include_directories(pcvc4-bin PRIVATE ${Boost_INCLUDE_DIRS})
-  install(TARGETS pcvc4-bin DESTINATION bin)
+  if(PROGRAM_PREFIX)
+    install(PROGRAMS
+      $<TARGET_FILE:pcvc4-bin> DESTINATION bin RENAME ${PROGRAM_PREFIX}pcvc4)
+  else()
+    install(TARGETS pcvc4-bin DESTINATION bin)
+  endif()
 
   if(NOT ENABLE_SHARED)
     set_target_properties(pcvc4-bin PROPERTIES LINK_FLAGS -static)