summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tomaz.canabrava@intel.com>2014-04-14 14:21:01 -0300
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-04-14 11:49:49 -0700
commit907d8b8fbbb0bc07ccc4c4b4d1374f764c5d8dae (patch)
treefd1600254012ecd9a31917ba99c538f3b2e8ee42 /CMakeLists.txt
parent3abcde9a2abade0ce576976b6dce869e8aa28601 (diff)
downloadsubsurface-907d8b8fbbb0bc07ccc4c4b4d1374f764c5d8dae.tar.gz
Add a CMake based buildsystem for the tests.
This commit adds a CMake based buildsystem for the tests, it separated the subsurface sources in small libraries to make testing easyer ( subsurface core, subsurface ui, subsurface profile, etc. ) There's no test yet, this however produces a compiled and executable binary *on linux*. This file shouldn't be needed on any other platform as this is not the main build system, but the test build system. Signed-off-by: Tomaz Canabrava <tomaz.canabrava@intel.com> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'CMakeLists.txt')
-rw-r--r--CMakeLists.txt116
1 files changed, 116 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 000000000..35736e674
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,116 @@
+project(Subsurface)
+cmake_minimum_required(VERSION 2.8)
+
+#options
+SET(SUBSURFACE_QT_VERSION "4")
+SET(CMAKE_AUTOMOC ON)
+SET(CMAKE_AUTOUIC ON)
+SET(CMAKE_MODULE_PATH ${${PROJECT_NAME}_SOURCE_DIR}/marbledata)
+
+if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUXX)
+ SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99 ")
+endif()
+
+INCLUDE_DIRECTORIES( . ${CMAKE_CURRENT_BINARY_DIR} ${CMAKE_BINARY_DIR} qt-ui qt-ui/profile)
+FIND_PACKAGE(PkgConfig)
+
+MACRO(pkg_config_library LIBNAME pcfile)
+ pkg_check_modules(${LIBNAME} ${pcfile})
+ include_directories(${${LIBNAME}_INCLUDE_DIRS})
+ link_directories(${${LIBNAME}_LIBRARY_DIRS})
+ add_definitions(${${LIBNAME}_CFLAGS_OTHER})
+ set(SUBSURFACE_LINK_LIBRARIES ${SUBSURFACE_LINK_LIBRARIES} ${${LIBNAME}_LIBRARIES})
+ENDMACRO()
+
+pkg_config_library(LIBXML libxml-2.0)
+pkg_config_library(LIBSQLITE3 sqlite3)
+pkg_config_library(LIBGIT2 libgit2)
+pkg_config_library(LIBXSLT libxslt)
+
+STRING(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}" "${${PROJECT_NAME}_BINARY_DIR}" insource)
+GET_FILENAME_COMPONENT(PARENTDIR ${${PROJECT_NAME}_SOURCE_DIR} PATH)
+STRING(COMPARE EQUAL "${${PROJECT_NAME}_SOURCE_DIR}" "${PARENTDIR}" insourcesubdir)
+IF(NOT (insource OR insourcedir))
+ add_custom_target(link_marble_data ALL COMMAND rm -f marbledata && ln -s ${${PROJECT_NAME}_SOURCE_DIR}/marbledata ${${PROJECT_NAME}_BINARY_DIR}/marbledata)
+ENDIF()
+
+#configure Qt version.
+IF(${SUBSURFACE_QT_VERSION} MATCHES "4")
+ SET(QT_USE_QTNETWORK TRUE)
+ SET(QT_USE_QTXML TRUE)
+ SET(QT_USE_QTSVG TRUE)
+ SET(QT_USE_QTTEST TRUE)
+ SET(QT_USE_QTWEBKIT TRUE)
+ FIND_PACKAGE(Qt4 REQUIRED)
+ INCLUDE(${QT_USE_FILE})
+ ADD_DEFINITIONS(${QT_DEFINITIONS})
+ FIND_PACKAGE(Marble REQUIRED)
+ INCLUDE_DIRECTORIES(${MARBLE_INCLUDE_DIR})
+ELSEIF(${SUBSURFACE_QT_VERSION} MATCHES "5")
+ ADD_DEFINITIONS(-DNO_MARBLE)
+ELSE()
+ message( FATAL_ERROR "Qt version should be 4 or 5" )
+ENDIF()
+
+# Generate the ssrf-config.h every 'make'
+FILE(WRITE ${CMAKE_BINARY_DIR}/version.h.in "\#define VERSION_STRING \"4.1.\"@VERSION@\n")
+FILE(WRITE ${CMAKE_BINARY_DIR}/version.cmake "EXECUTE_PROCESS(
+ COMMAND date +\"%s\"
+ OUTPUT_VARIABLE VERSION
+ OUTPUT_STRIP_TRAILING_WHITESPACE
+ )
+ CONFIGURE_FILE(\${SRC} \${DST} @ONLY)
+")
+ADD_CUSTOM_TARGET(version ALL COMMAND
+ ${CMAKE_COMMAND} -D SRC=${CMAKE_BINARY_DIR}/version.h.in
+ -D DST=${CMAKE_BINARY_DIR}/ssrf-version.h
+ -P ${CMAKE_BINARY_DIR}/version.cmake
+)
+
+# compile the core library, in C.
+FILE(GLOB SUBSURFACE_CORE_LIB_SRCS *.c)
+LIST(REMOVE_ITEM SUBSURFACE_CORE_LIB_SRCS
+ ${CMAKE_CURRENT_SOURCE_DIR}/windows.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/macos.c
+ ${CMAKE_CURRENT_SOURCE_DIR}/cochran.c
+)
+
+FILE(GLOB SUBSURFACE_PROFILE_LIB_SRCS qt-ui/profile/*.cpp)
+FILE(GLOB SUBSURFACE_UI qt-ui/*.ui)
+FILE(GLOB SUBSURFACE_INTERFACE qt-ui/*.cpp)
+FILE(GLOB SUBSURFACE_APP *.cpp )
+IF(NOT (CMAKE_SYSTEM_NAME MATCHES Android))
+ LIST(REMOVE_ITEM SUBSURFACE_APP ${CMAKE_CURRENT_SOURCE_DIR}/android.cpp)
+ENDIF()
+
+# to be replaced by QT_WRAP_UI on CMake 3.
+IF(${SUBSURFACE_QT_VERSION} MATCHES "4")
+ QT4_WRAP_UI( SUBSURFACE_UI_HDRS ${SUBSURFACE_UI} )
+ QT4_ADD_RESOURCES( SUBSURFACE_QRC_HRDS subsurface.qrc )
+ELSEIF(${SUBSURFACE_QT_VERSION} MATCHES "5")
+ QT5_WRAP_UI( SUBSURFACE_UI_HDRS ${SUBSURFACE_UI} )
+ENDIF()
+
+ADD_LIBRARY(subsurface_corelib STATIC ${SUBSURFACE_CORE_LIB_SRCS} )
+ADD_LIBRARY(subsurface_profile STATIC ${SUBSURFACE_PROFILE_LIB_SRCS})
+ADD_LIBRARY(subsurface_generated_ui STATIC ${SUBSURFACE_UI_HDRS})
+ADD_LIBRARY(subsurface_interface STATIC ${SUBSURFACE_INTERFACE})
+ADD_EXECUTABLE(subsurface ${SUBSURFACE_APP} ${SUBSURFACE_QRC_HRDS} )
+
+target_link_libraries( subsurface
+ subsurface_generated_ui
+ subsurface_interface
+ subsurface_profile
+ subsurface_corelib
+ ${QT_LIBRARIES}
+ ${MARBLE_LIBRARIES}
+ ${SUBSURFACE_LINK_LIBRARIES}
+ -ldivecomputer
+ -lzip
+)
+
+ADD_DEPENDENCIES(subsurface_profile subsurface_generated_ui)
+ADD_DEPENDENCIES(subsurface_interface subsurface_generated_ui)
+ADD_DEPENDENCIES(subsurface_generated_ui version)
+
+ENABLE_TESTING()