Criterion/CMakeLists.txt

150 lines
3.5 KiB
Text
Raw Permalink Normal View History

# Copyright (C) 2015-2016 Franklin "Snaipe" Mathieu.
# Redistribution and use of this file is allowed according to the terms of the MIT license.
# For details see the LICENSE file distributed with Criterion.
2015-07-28 19:03:46 +02:00
cmake_minimum_required (VERSION 2.8)
project (Criterion C)
set (MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
2015-11-27 15:53:10 +01:00
if (POLICY CMP0054)
# http://www.cmake.org/cmake/help/v3.1/policy/CMP0054.html
# This is here to allow conditions to be passed as function parameters
cmake_policy (SET CMP0054 OLD)
endif ()
# Initialization
include (Options)
include (Submodules)
include (Capabilities)
include (Subprojects)
include (PackageUtils)
2016-04-23 14:08:27 +02:00
if (NOT WIN32)
set (PIC_C_FLAGS "-fPIC")
set (VISI_C_FLAGS "-fvisibility=hidden")
else ()
set (PIC_C_FLAGS "")
set (VISI_C_FLAGS "")
2016-04-23 14:08:27 +02:00
endif ()
cr_add_subproject (csptr PATH dependencies/libcsptr
OPTS
-DLIBCSPTR_TESTS=OFF
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE)
cr_add_subproject (dyncall_s PATH dependencies/dyncall
OPTS
-DLANG_CXX=${LANG_CXX}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE IF THEORIES)
cr_add_subproject (nanomsg
PATH dependencies/nanomsg
2016-04-23 14:08:27 +02:00
OPTS
-DNN_TESTS=OFF
-DNN_TOOLS=OFF
-DNN_STATIC_LIB=ON
-DCMAKE_INSTALL_LIBDIR=lib
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
CMAKE
)
2016-08-08 15:59:13 +02:00
cr_add_subproject (boxfort PATH dependencies/boxfort
OPTS
-DBXF_TESTS=OFF
-DBXF_SAMPLES=OFF
-DBXF_STATIC_LIB=ON
-DBXF_FORK_RESILIENCE=OFF
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
"-DCMAKE_C_FLAGS=${CMAKE_C_FLAGS} ${PIC_C_FLAGS} ${VISI_C_FLAGS}"
2016-08-08 15:59:13 +02:00
CMAKE)
2016-09-01 01:36:58 +02:00
add_definitions(-DBXF_STATIC_LIB -DNN_STATIC_LIB)
cr_add_subproject (wingetopt PATH dependencies/wingetopt CMAKE IF MSVC)
include (Properties)
2016-02-06 22:15:44 +01:00
add_definitions (-DNN_STATIC_LIB)
include_directories(
dependencies/valgrind/include/
2015-10-11 13:21:23 +01:00
dependencies/klib/
dependencies/nanopb/
dependencies/debugbreak/
)
# Coverage
if (COVERALLS)
include(Coveralls)
coveralls_turn_on_coverage()
endif()
# I18N
2015-11-27 15:53:10 +01:00
if (I18N AND GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
include(GettextTranslate)
add_subdirectory(po)
endif ()
# Project
include_directories(include src)
add_subdirectory (src)
cr_add_library(criterion SHARED
SOURCES ${SOURCE_FILES}
HEADERS ${INTERFACE_FILES}
COMPONENT dev
PROPERTIES
VERSION ${PROJECT_SONAME}
SOVERSION ${PROJECT_SOVERSION}
)
cr_link_subproject(criterion csptr STATIC)
cr_link_subproject(criterion nanomsg STATIC)
cr_link_subproject(criterion dyncall_s STATIC)
cr_link_subproject(criterion wingetopt STATIC)
2016-08-08 15:59:13 +02:00
cr_link_subproject(criterion boxfort STATIC)
2015-11-27 15:53:10 +01:00
cr_link_libraries(criterion pthread IF NOT WIN32)
cr_link_libraries(criterion rt IF HAVE_LIBRT)
2016-02-06 22:15:44 +01:00
# Required by nanomsg
cr_link_libraries(criterion anl IF HAVE_GETADDRINFO_A)
2016-02-06 22:15:44 +01:00
cr_link_libraries(criterion ws2_32 mswsock IF WIN32)
cr_link_package(criterion LIBINTL)
if (COVERALLS)
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
add_custom_target(gcov
"${CMAKE_COMMAND}"
-DSOURCE_FILES="${SOURCE_FILES}"
-DCOV_PATH="${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_MODULE_PATH}/Gcov.cmake"
)
endif()
2015-09-04 04:52:44 +02:00
2016-09-04 11:27:21 +02:00
add_custom_target(uninstall
"${CMAKE_COMMAND}" -P "${CMAKE_MODULE_PATH}/uninstall.cmake"
)
2015-09-22 00:16:45 +02:00
if (CTESTS)
enable_testing()
add_custom_target(criterion_tests)
add_subdirectory(samples)
add_subdirectory(test)
endif ()
if (UPLOAD_DEB)
include (DebUpload)
endif ()