Changeset ddd39f2 in subsurface


Ignore:
Timestamp:
Jun 11, 2017, 1:50:30 PM (2 months ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
master
Children:
3f4f245
Parents:
3775f45
git-author:
Salvador Cuñat <salvador.cunat@…> (06/05/17 12:28:21)
git-committer:
Dirk Hohndel <dirk@…> (06/11/17 13:50:30)
Message:

smtk-import: change CMakeLists.txt

As SmartTrak? importer is building separately from Subsurface, a full
CMakeLists.txt file is necessary for the smtk-import directory.
It includes cross building to windows capability.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • smtk-import/CMakeLists.txt

    r56b442f rddd39f2  
     1# Modified from Subsurface's CMakeLists.txt
     2
     3project(smtk2ssrf)
     4cmake_minimum_required(VERSION 2.8.11)
     5
     6set(CMAKE_AUTOMOC ON)
    17set(CMAKE_AUTOUIC ON)
    28set(CMAKE_INCLUDE_CURRENT_DIR ON)
     9set(CMAKE_BUILD_TYPE "Release")
     10
     11set(SSRF_PATH ../)
     12set(CMAKE_MODULE_PATH ${SSRF_PATH}cmake/Modules)
     13include(${CMAKE_MODULE_PATH}/MacroOutOfSourceBuild.cmake)
     14include(${CMAKE_MODULE_PATH}/cmake_variables_helper.cmake)
     15if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     16        include(${CMAKE_MODULE_PATH}/HandleVersionGeneration.cmake)
     17endif()
     18
     19MACRO_ENSURE_OUT_OF_SOURCE_BUILD(
     20    "We don't support building in source, please create a build folder elsewhere and remember to run git clean -xdf to remove temporary files created by CMake."
     21)
     22
     23# Find needed packages and Qt5 components. Most of them needed by Subsurface
     24find_package(PkgConfig)
     25include(${SSRF_PATH}cmake/Modules/pkgconfig_helper.cmake)
     26pkg_config_library(LIBXML libxml-2.0 REQUIRED)
     27pkg_config_library(LIBSQLITE3 sqlite3 REQUIRED)
     28pkg_config_library(LIBXSLT libxslt REQUIRED)
     29pkg_config_library(LIBZIP libzip REQUIRED)
     30pkg_config_library(LIBUSB libusb-1.0 QUIET)
     31pkg_config_library(GLIB2 glib-2.0 REQUIRED)
     32pkg_config_library(LIBGIT2 libgit2 REQUIRED)
     33pkg_config_library(LIBMDB libmdb REQUIRED)
     34pkg_config_library(LIBDC libdivecomputer REQUIRED)
     35
     36find_package(Qt5 REQUIRED COMPONENTS Core
     37                                     Concurrent
     38                                     Widgets
     39                                     Network
     40                                     Svg
     41                                     Test
     42                                     LinguistTools
     43                                     Positioning
     44                                     Bluetooth)
     45
     46set(QT_LIBRARIES Qt5::Core
     47                 Qt5::Concurrent
     48                 Qt5::Widgets
     49                 Qt5::Network
     50                 Qt5::Svg
     51                 Qt5::Positioning
     52                 Qt5::Bluetooth)
     53
     54set(QT5_INCLUDE_PATH ${Qt5_INCLUDE_DIRS} ${Qt5Widgets_INCLUDE_DIRS} ${Qt5Core_INCLUDE_DIRS})
     55qt5_add_resources(SUBSURFACE_RESOURCES ${SSRF_PATH}subsurface.qrc)
     56
     57include_directories(${SSRF_PATH} ${QT5_INCLUDE_PATH} ${LIBMDB_INCLUDEDIR} ${LIBDIVECOMPUTER_INCLUDEDIR})
     58
     59# Check for libsubsurface_corelib.a
     60# A previous build of subsurface is needed (windows and linux)
     61message(STATUS "Checking for Subsurface core library")
     62if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     63        find_library(SSRF_CORELIB
     64                NAMES subsurface_corelib
     65                PATHS ${CMAKE_BINARY_DIR}/../subsurface/core
     66                )
     67elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     68        find_library(SSRF_CORELIB
     69                NAMES subsurface_corelib
     70                PATHS ${SSRF_PATH}build/core
     71                )
     72endif()
     73
     74if(NOT DEFINED SSRF_CORELIB OR SSRF_CORELIB STREQUAL "SSRF_CORELIB-NOTFOUND")
     75        message(FATAL_ERROR "  libsubsurface_corelib.a not found. Did you build Subsurface previously?")
     76else()
     77        message(STATUS "  Found ${SSRF_CORELIB}")
     78endif()
     79
     80# Set compiler flags and definitions
     81set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99")
     82set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -fPIC")
     83
     84if(CMAKE_SYSTEM_NAME STREQUAL "Linux")
     85        set(SMTK_LINK_LIBRARIES ${SMTK_LINK_LIBRARIES} -lssh2 -lz -lpthread)
     86elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     87        set(SMTK_LINK_LIBRARIES ${SMTK_LINK_LIBRARIES} -lwsock32 -lws2_32 -lole32 -limm32 -lwinmm)
     88        remove_definitions(-DUNICODE)
     89        add_definitions(-mwindows -D_WIN32)
     90endif()
     91
     92set(SMTK_LINK_LIBRARIES ${SMTK_LINK_LIBRARIES} ${LIBMDB_LIBRARIES} ${LIBDIVECOMPUTER_LIBRARIES})
     93
    394set(SMTK_IMPORT_SRCS
    495        smartrak.c
     
    798        smrtk2ssrfc_window.cpp
    899)
     100set(SMTK_LINK_LIBRARIES ${SMTK_LINK_LIBRARIES} ${SUBSURFACE_LINK_LIBRARIES} ${SSRF_CORELIB} ${QT_LIBRARIES})
     101source_group("SmartTrak Import libs" FILES ${SMTK_IMPORT_SRCS})
     102set(SMTK_IMPORT_TARGET smtk2ssrf)
     103add_library(smtk_import STATIC ${SMTK_IMPORT_SRCS})
     104add_executable(${SMTK_IMPORT_TARGET} smtk_standalone.cpp ${SUBSURFACE_RESOURCES})
    9105
    10 source_group("SmartTrak Import libs" FILES ${SMTK_IMPORT_SRCS})
    11 add_library(smtk_import STATIC ${SMTK_IMPORT_SRCS})
    12 target_link_libraries(smtk_import subsurface_corelib ${SUBSURFACE_LINK_LIBRARIES})
     106if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     107        add_custom_command(
     108                OUTPUT ${CMAKE_BINARY_DIR}/qt.conf
     109                COMMAND echo \"[Paths]\" > ${CMAKE_BINARY_DIR}/qt.conf \; echo \"Prefix=.\" >> ${CMAKE_BINARY_DIR}/qt.conf
     110        )
     111        add_custom_target(
     112                generate_qtconf
     113                DEPENDS ${CMAKE_BINARY_DIR}/qt.conf
     114        )
     115        add_dependencies(${SMTK_IMPORT_TARGET} generate_qtconf)
     116endif()
     117
     118target_link_libraries(${SMTK_IMPORT_TARGET} smtk_import ${SMTK_LINK_LIBRARIES})
     119
     120# Install instructions
     121if (CMAKE_SYSTEM_NAME STREQUAL "Linux")
     122        install(TARGETS ${SMTK_IMPORT_TARGET} DESTINATION bin)
     123elseif(CMAKE_SYSTEM_NAME STREQUAL "Windows")
     124        set(WINDOWSSTAGING ${CMAKE_BINARY_DIR}/staging)
     125        install(FILES ${SSRF_PATH}gpl-2.0.txt ${SSRF_PATH}packaging/windows/subsurface.ico DESTINATION ${WINDOWSSTAGING})
     126        install(TARGETS ${SMTK_IMPORT_TARGET} DESTINATION ${WINDOWSSTAGING})
     127        install(FILES ${CMAKE_BINARY_DIR}/qt.conf DESTINATION ${WINDOWSSTAGING})
     128        if(NOT DEFINED MAKENSIS)
     129                set(MAKENSIS makensis)
     130        endif()
     131
     132        # this ensures that smtk2ssrf.exe has been built before this is run
     133        install(CODE "execute_process(COMMAND ${CMAKE_COMMAND} -DCMAKE_C_COMPILER=${CMAKE_C_COMPILER} -DSMTK_IMPORT_TARGET=${SMTK_IMPORT_TARGET} -DSMTK_IMPORT_SRCS=${SMTK_IMPORT_SRCS} -DSTAGING=${WINDOWSSTAGING} -P ${CMAKE_SOURCE_DIR}/cmake/Modules/dlllist.cmake)")
     134
     135        # create the smtk2ssrf-x.y.z.exe installer - this needs to depend
     136        # on the install target but cmake doesn't allow that, so we depend
     137        # on the fake target instead
     138        add_custom_target(
     139                fake_install
     140                COMMAND "${CMAKE_COMMAND}" --build . --target install
     141                DEPENDS ${SMTK_IMPORT_TARGET}
     142        )
     143
     144        add_custom_target(
     145                installer
     146                COMMAND ${MAKENSIS} ${WINDOWSSTAGING}/smtk-import.nsi
     147                DEPENDS fake_install
     148        )
     149endif()
     150
     151# useful for debugging CMake issues
     152# printll_variables()
Note: See TracChangeset for help on using the changeset viewer.