summaryrefslogtreecommitdiffstats
path: root/smtk-import
diff options
context:
space:
mode:
authorGravatar Salvador Cuñat <salvador.cunat@gmail.com>2017-06-05 21:47:19 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-06-11 13:50:30 -0700
commitb012258617b4571cccfe1bfb8d2b7487b518f4b9 (patch)
tree776e9eee52f78af45d3ad71a9c0aaaa517a447a0 /smtk-import
parent3f4f2455d331541a600a435ec2723aa3b56bcf19 (diff)
downloadsubsurface-b012258617b4571cccfe1bfb8d2b7487b518f4b9.tar.gz
smtk-import: add cmake modules and .nsi skeleton
Needed to crossbuild to windows. The cmake modules are just clones from those under subsurface/cmake/Modules, tweaked to build smtk-import for windows.
Diffstat (limited to 'smtk-import')
-rw-r--r--smtk-import/cmake/Modules/dlllist.cmake42
-rw-r--r--smtk-import/cmake/Modules/version.cmake24
2 files changed, 66 insertions, 0 deletions
diff --git a/smtk-import/cmake/Modules/dlllist.cmake b/smtk-import/cmake/Modules/dlllist.cmake
new file mode 100644
index 000000000..6aa107f66
--- /dev/null
+++ b/smtk-import/cmake/Modules/dlllist.cmake
@@ -0,0 +1,42 @@
+message(STATUS "processing dlllist.cmake")
+
+# figure out which command to use for objdump
+execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -dumpmachine
+ OUTPUT_VARIABLE OBJDUMP
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# figure out where we should search for libraries
+execute_process(
+ COMMAND ${CMAKE_C_COMPILER} -print-search-dirs
+ COMMAND sed -nE "/^libraries: =/{s///;s,/lib/?\(:|\$\$\),/bin\\1,g;p;q;}"
+ OUTPUT_VARIABLE ADDPATH
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+message(STATUS "addpath is ${ADDPATH}")
+# since cmake doesn't appear to give us a variable with
+# all libraries we link against, grab the link.txt script
+# instead and drop the command name from it (before the
+# first space) -- this will fail if the full path for the
+# linker used contains a space...
+execute_process(
+ COMMAND tail -1 CMakeFiles/${SMTK_IMPORT_TARGET}.dir/link.txt
+ COMMAND cut -d\ -f 2-
+ OUTPUT_VARIABLE LINKER_LINE
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# finally run our win-ldd.pl script against that to
+# collect all the required dlls
+execute_process(
+ COMMAND sh -c "OBJDUMP=${OBJDUMP}-objdump PATH=$ENV{PATH}:${ADDPATH} perl '../../subsurface/scripts/win-ldd.pl' ${SMTK_IMPORT_TARGET}.exe ${LINKER_LINE}"
+ WORKING_DIRECTORY ${CMAKE_BINARY_DIR}
+ OUTPUT_VARIABLE DLLS
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+# replace newlines with semicolons so this is a cmake list
+string(REPLACE "\n" ";" DLLLIST ${DLLS})
+# executing 'install' as a command seems hacky, but you
+# can't use the install() cmake function in a script
+foreach(DLL ${DLLLIST})
+ execute_process(COMMAND install ${DLL} ${STAGING})
+endforeach()
diff --git a/smtk-import/cmake/Modules/version.cmake b/smtk-import/cmake/Modules/version.cmake
new file mode 100644
index 000000000..1d6b0f474
--- /dev/null
+++ b/smtk-import/cmake/Modules/version.cmake
@@ -0,0 +1,24 @@
+message(STATUS "processing version.cmake")
+execute_process(
+ COMMAND sh ${CMAKE_TOP_SRC_DIR}/../scripts/get-version linux
+ WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
+ OUTPUT_VARIABLE GIT_VERSION_STRING
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+execute_process(
+ COMMAND sh ${CMAKE_TOP_SRC_DIR}/../scripts/get-version full
+ WORKING_DIRECTORY ${CMAKE_TOP_SRC_DIR}
+ OUTPUT_VARIABLE CANONICAL_VERSION_STRING
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+)
+set(MOBILE_VERSION_STRING "1.2.1")
+
+configure_file(${SRC} ${DST} @ONLY)
+if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
+ execute_process(
+ COMMAND cat ${CMAKE_TOP_SRC_DIR}/../packaging/windows/smtk-import.nsi.in
+ COMMAND sed -e "s/VERSIONTOKEN/${GIT_VERSION_STRING}/"
+ COMMAND sed -e "s/PRODVTOKEN/${CANONICAL_VERSION_STRING}/"
+ OUTPUT_FILE ${CMAKE_BINARY_DIR}/staging/smtk-import.nsi
+ )
+endif()