[Issue #96] Refactored the build system configuration
This commit is contained in:
parent
70c0593e23
commit
dc62c45c08
8 changed files with 511 additions and 385 deletions
|
@ -1,8 +1,25 @@
|
|||
# Copyright (C) 2015 Franklin "Snaipe" Mathieu.
|
||||
# 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.
|
||||
|
||||
include(CheckPrototypeDefinition)
|
||||
include(CheckLibraryExists)
|
||||
include(PackageUtils)
|
||||
|
||||
# Check for packages
|
||||
|
||||
cr_find_package (Gettext)
|
||||
cr_find_package (Libintl)
|
||||
|
||||
if (I18N AND GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
|
||||
set (GettextTranslate_ALL 1)
|
||||
set (GettextTranslate_GMO_BINARY 1)
|
||||
set (ENABLE_NLS 1)
|
||||
endif ()
|
||||
|
||||
cr_find_package (PCRE PKGCONFIG libpcre)
|
||||
|
||||
# Check for functions
|
||||
|
||||
check_prototype_definition(
|
||||
strtok_s
|
||||
|
@ -10,3 +27,31 @@ check_prototype_definition(
|
|||
NULL
|
||||
"string.h"
|
||||
HAVE_STRTOK_S)
|
||||
|
||||
check_library_exists (rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
|
||||
|
||||
# Check for C++11
|
||||
|
||||
if (LANG_CXX)
|
||||
enable_language(CXX)
|
||||
endif ()
|
||||
|
||||
if (NOT MSVC AND CMAKE_CXX_COMPILER_WORKS)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
set(CXX11_FLAG "-std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CXX11_FLAG "-std=c++0x")
|
||||
else()
|
||||
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Valgrind support
|
||||
|
||||
if (DEV_BUILD)
|
||||
set(ENABLE_VALGRIND_ERRORS 1)
|
||||
endif ()
|
||||
|
|
9
.cmake/Modules/DebUpload.cmake
Normal file
9
.cmake/Modules/DebUpload.cmake
Normal file
|
@ -0,0 +1,9 @@
|
|||
# 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.
|
||||
|
||||
# Add toolchain patch number for incremental deb builds
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION}-2")
|
||||
|
||||
include (PackageConfig)
|
||||
include (DebConfig)
|
13
.cmake/Modules/Options.cmake
Normal file
13
.cmake/Modules/Options.cmake
Normal file
|
@ -0,0 +1,13 @@
|
|||
# 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.
|
||||
|
||||
option(LANG_CXX "Turn on C++ support" ON)
|
||||
option(THEORIES "Activate the support for theories" ON)
|
||||
option(MINGW_DEFINE_OFF_T "Define off_t and off64_t ourselves before including io.h" OFF)
|
||||
option(COVERALLS "Turn on coveralls support" OFF)
|
||||
option(COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
|
||||
option(DEV_BUILD "Compile in developer mode" OFF)
|
||||
option(CTESTS "Turn on the samples and test" ${DEV_BUILD})
|
||||
option(I18N "Turn on internationalization" ON)
|
||||
option(UPLOAD_DEB "Upload package to launchpad" OFF)
|
97
.cmake/Modules/PackageUtils.cmake
Normal file
97
.cmake/Modules/PackageUtils.cmake
Normal file
|
@ -0,0 +1,97 @@
|
|||
# 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.
|
||||
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function (cr_link_package _TARGET _PKG)
|
||||
if (${_PKG}_LIB_FOUND OR ${_PKG}_FOUND)
|
||||
target_link_libraries(${_TARGET} ${${_PKG}_LIBRARIES})
|
||||
include_directories(${${_PKG}_INCLUDE_DIRS})
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
function (cr_link_libraries _TARGET)
|
||||
set (multiValueArgs IF)
|
||||
cmake_parse_arguments (ARGS "" "" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (ARGS_IF)
|
||||
if (${ARGS_IF})
|
||||
else ()
|
||||
return ()
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
target_link_libraries(${_TARGET} ${ARGS_UNPARSED_ARGUMENTS})
|
||||
endfunction ()
|
||||
|
||||
function (cr_add_library _LIB)
|
||||
set (options SHARED STATIC)
|
||||
set (oneValueArgs COMPONENT)
|
||||
set (multiValueArgs SOURCES HEADERS PROPERTIES)
|
||||
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
set (flags "")
|
||||
if (ARGS_SHARED)
|
||||
set (flags ${flags} SHARED)
|
||||
elseif (ARGS_STATIC)
|
||||
set (flags ${flags} STATIC)
|
||||
endif ()
|
||||
|
||||
add_library(${_LIB} ${flags} ${ARGS_SOURCES} ${ARGS_HEADERS})
|
||||
set_target_properties(${_LIB} PROPERTIES ${ARGS_PROPERTIES})
|
||||
|
||||
foreach (F ${INTERFACE_FILES})
|
||||
get_filename_component(DEST "${F}" PATH)
|
||||
if (ARGS_COMPONENT)
|
||||
set (install_flags COMPONENT ${ARGS_COMPONENT})
|
||||
endif ()
|
||||
install(FILES "${F}" DESTINATION "${DEST}" ${install_flags})
|
||||
endforeach ()
|
||||
|
||||
install(TARGETS ${_LIB}
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib ${install_flags}
|
||||
)
|
||||
endfunction ()
|
||||
|
||||
find_package(PkgConfig)
|
||||
|
||||
macro (cr_find_package _PKG)
|
||||
set (options REQUIRED)
|
||||
set (oneValueArgs PKGCONFIG)
|
||||
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "" ${ARGN})
|
||||
|
||||
string (TOUPPER "${_PKG}" _PKG_UP)
|
||||
|
||||
find_package (${_PKG})
|
||||
if (NOT ${_PKG_UP}_FOUND AND ${_PKG_UP}_LIB_FOUND)
|
||||
set (${_PKG_UP}_FOUND ON)
|
||||
endif ()
|
||||
|
||||
if (NOT ${_PKG_UP}_FOUND AND PKGCONFIG_FOUND)
|
||||
message (STATUS "Checking for package ${_PKG} with pkg-config")
|
||||
if (NOT ARGS_PKGCONFIG)
|
||||
set (ARGS_PKGCONFIG ${_PKG})
|
||||
endif ()
|
||||
pkg_check_modules(${_PKG_UP}_PKG ${ARGS_PKGCONFIG})
|
||||
|
||||
if (${_PKG_UP}_PKG_FOUND)
|
||||
if (${_PKG_UP}_PKG_LIBRARY_DIRS)
|
||||
link_directories(${PCRE_PKG_LIBRARY_DIRS})
|
||||
endif ()
|
||||
set (${_PKG_UP}_LIBRARIES ${${_PKG_UP}_PKG_LIBRARIES})
|
||||
set (${_PKG_UP}_INCLUDE_DIRS ${${_PKG_UP}_PKG_INCLUDE_DIRS})
|
||||
set (${_PKG_UP}_FOUND 1)
|
||||
endif()
|
||||
endif ()
|
||||
|
||||
if (NOT ${_PKG_UP}_FOUND AND ARGS_REQUIRED)
|
||||
message (FATAL_ERROR "Could not find required package ${_PKG}")
|
||||
endif ()
|
||||
|
||||
if (${_PKG_UP}_FOUND)
|
||||
set (HAVE_${_PKG_UP} 1)
|
||||
endif ()
|
||||
endmacro ()
|
35
.cmake/Modules/Properties.cmake
Normal file
35
.cmake/Modules/Properties.cmake
Normal file
|
@ -0,0 +1,35 @@
|
|||
# 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.
|
||||
|
||||
set (PROJECT_VERSION "2.2.0")
|
||||
set (PROJECT_SOVERSION 3)
|
||||
set (LOCALEDIR_REL "share/locale")
|
||||
set (LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LOCALEDIR_REL}")
|
||||
|
||||
add_definitions(
|
||||
-DCRITERION_BUILDING_DLL=1
|
||||
-DPB_ENABLE_MALLOC=1
|
||||
)
|
||||
|
||||
set (CMAKE_C_FLAGS_DEFAULT "${CMAKE_C_FLAGS}")
|
||||
set (CMAKE_CXX_FLAGS_DEFAULT "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if (MSVC)
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
|
||||
add_definitions (-D_CRT_SECURE_NO_WARNINGS=1)
|
||||
else ()
|
||||
if (WIN32)
|
||||
set (CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
|
||||
endif ()
|
||||
|
||||
set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99")
|
||||
if (CMAKE_CXX_COMPILER_WORKS)
|
||||
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -g ${CXX11_FLAG}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
include_directories(SYSTEM
|
||||
/usr/local/include
|
||||
/usr/include/GNUstep
|
||||
)
|
110
.cmake/Modules/Subprojects.cmake
Normal file
110
.cmake/Modules/Subprojects.cmake
Normal file
|
@ -0,0 +1,110 @@
|
|||
# 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.
|
||||
|
||||
include(ExternalProject)
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function (cr_add_subproject _NAME)
|
||||
set (options CMAKE AUTOTOOLS)
|
||||
set (oneValueArgs GIT PATH PREFIX)
|
||||
set (multiValueArgs OPTS IF)
|
||||
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (ARGS_IF)
|
||||
if (${ARGS_IF})
|
||||
set (${_NAME}_SUBPROJECT_EXISTS 1 PARENT_SCOPE)
|
||||
else ()
|
||||
return ()
|
||||
endif ()
|
||||
else ()
|
||||
set (${_NAME}_SUBPROJECT_EXISTS 1 PARENT_SCOPE)
|
||||
endif ()
|
||||
|
||||
if (ARGS_PREFIX)
|
||||
set (install_prefix ${CMAKE_BINARY_DIR}/external/${ARGS_PREFIX})
|
||||
else ()
|
||||
set (install_prefix ${CMAKE_BINARY_DIR}/external)
|
||||
endif ()
|
||||
|
||||
if (ARGS_GIT)
|
||||
string(REPLACE "#" ";" git_opts "${ARGS_GIT}")
|
||||
list(LENGTH git_opts git_opts_len)
|
||||
list(GET git_opts 0 repo)
|
||||
set (epa_opts GIT_REPOSITORY "${repo}")
|
||||
if (git_opts_len GREATER 1)
|
||||
list(GET git_opts 1 object)
|
||||
set (epa_opts ${epa_opts} GIT_TAG "${object}")
|
||||
endif ()
|
||||
elseif (ARGS_PATH)
|
||||
set (epa_opts SOURCE_DIR "${CMAKE_SOURCE_DIR}/${ARGS_PATH}")
|
||||
endif ()
|
||||
|
||||
if (ARGS_CMAKE)
|
||||
set (build_cmds
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} <SOURCE_DIR>
|
||||
-DCMAKE_INSTALL_PREFIX=${install_prefix}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
${ARGS_OPTS}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}"
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}" --target install
|
||||
)
|
||||
elseif (ARGS_AUTOTOOLS)
|
||||
set (make_opts "")
|
||||
if (ARGS_PARALLELIZED)
|
||||
set (make_opts "${make_opts} -j4")
|
||||
endif ()
|
||||
set (build_cmds
|
||||
UPDATE_COMMAND <SOURCE_DIR>/autogen.sh
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=${install_prefix} ${ARGS_OPTS}
|
||||
BUILD_COMMAND make ${make_opts}
|
||||
INSTALL_COMMAND make install
|
||||
)
|
||||
endif ()
|
||||
|
||||
externalproject_add(
|
||||
${_NAME}
|
||||
${epa_opts}
|
||||
|
||||
PREFIX "${CMAKE_BINARY_DIR}/${_NAME}-build"
|
||||
BINARY_DIR "${CMAKE_BINARY_DIR}/${_NAME}"
|
||||
|
||||
${build_cmds}
|
||||
)
|
||||
|
||||
if (WIN32)
|
||||
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/${_NAME}.dll" PARENT_SCOPE)
|
||||
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/${_NAME}.lib" PARENT_SCOPE)
|
||||
elseif (APPLE)
|
||||
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/lib${_NAME}.dylib" PARENT_SCOPE)
|
||||
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
|
||||
elseif (UNIX)
|
||||
set ("${_NAME}_SHARED_LIB" "${install_prefix}/lib/lib${_NAME}.so" PARENT_SCOPE)
|
||||
set ("${_NAME}_STATIC_LIB" "${install_prefix}/lib/lib${_NAME}.a" PARENT_SCOPE)
|
||||
else ()
|
||||
message (FATAL_ERROR "Could not set proper library path for the current platform")
|
||||
endif ()
|
||||
|
||||
endfunction ()
|
||||
|
||||
function (cr_link_subproject _TARGET _SUBPROJECT)
|
||||
if (NOT ${_SUBPROJECT}_SUBPROJECT_EXISTS)
|
||||
return ()
|
||||
endif ()
|
||||
|
||||
set (options STATIC SHARED)
|
||||
cmake_parse_arguments (ARGS "${options}" "" "" ${ARGN})
|
||||
|
||||
add_dependencies("${_TARGET}" "${_SUBPROJECT}")
|
||||
if (ARGS_SHARED)
|
||||
target_link_libraries("${_TARGET}" "${${_SUBPROJECT}_SHARED_LIB}")
|
||||
endif ()
|
||||
if (ARGS_STATIC)
|
||||
target_link_libraries("${_TARGET}" "${${_SUBPROJECT}_STATIC_LIB}")
|
||||
endif ()
|
||||
endfunction ()
|
||||
|
||||
include_directories(${CMAKE_BINARY_DIR}/external/include)
|
||||
link_directories(${CMAKE_BINARY_DIR}/external/lib)
|
||||
|
||||
|
448
CMakeLists.txt
448
CMakeLists.txt
|
@ -1,431 +1,111 @@
|
|||
cmake_minimum_required(VERSION 2.8)
|
||||
# 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.
|
||||
|
||||
project(Criterion C)
|
||||
cmake_minimum_required (VERSION 2.8)
|
||||
|
||||
set(MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
|
||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
|
||||
set(LIBCSPTR_DISABLE_TESTS ON)
|
||||
set(LIBCSPTR_DISABLE_COVERALLS ON)
|
||||
project (Criterion C)
|
||||
|
||||
# Content options
|
||||
set (MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
|
||||
set (CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
|
||||
|
||||
option(THEORIES "Activate the support for theories" ON)
|
||||
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(Submodules)
|
||||
include(Capabilities)
|
||||
include (Options)
|
||||
include (Properties)
|
||||
include (Submodules)
|
||||
include (Capabilities)
|
||||
include (Subprojects)
|
||||
include (PackageUtils)
|
||||
|
||||
if (MSVC)
|
||||
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
||||
endif ()
|
||||
cr_add_subproject (csptr PATH dependencies/libcsptr CMAKE)
|
||||
cr_add_subproject (dyncall_s PATH dependencies/dyncall CMAKE IF THEORIES)
|
||||
|
||||
add_subdirectory(dependencies/libcsptr/ EXCLUDE_FROM_ALL)
|
||||
|
||||
include(ExternalProject)
|
||||
include(CMakeParseArguments)
|
||||
|
||||
function (add_cmake_subproject _NAME)
|
||||
set (options)
|
||||
set (oneValueArgs GIT PATH PREFIX)
|
||||
set (multiValueArgs OPTS)
|
||||
cmake_parse_arguments (ARGS "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
||||
|
||||
if (NOT "${ARGS_PREFIX}" STREQUAL "")
|
||||
set (install_prefix ${CMAKE_BINARY_DIR}/external/${ARGS_PREFIX})
|
||||
else ()
|
||||
set (install_prefix ${CMAKE_BINARY_DIR}/external)
|
||||
endif ()
|
||||
|
||||
if (NOT "${ARGS_GIT}" STREQUAL "")
|
||||
string(REPLACE "#" ";" git_opts ${ARGS_GIT})
|
||||
list(LENGTH ${git_opts} git_opts_len)
|
||||
list(GET 0 repo)
|
||||
set (epa_opts GIT_REPOSITORY "${repo}")
|
||||
if (git_opts_len GREATER 1)
|
||||
list(GET 1 object)
|
||||
set (epa_opts ${epa_opts} GIT_TAG "${object}")
|
||||
endif ()
|
||||
elseif (NOT "${ARGS_PATH}" STREQUAL "")
|
||||
set (epa_opts SOURCE_DIR "${CMAKE_SOURCE_DIR}/${ARGS_PATH}")
|
||||
endif ()
|
||||
|
||||
externalproject_add(
|
||||
${_NAME}
|
||||
${epa_opts}
|
||||
|
||||
BINARY_DIR "${CMAKE_BINARY_DIR}/${_NAME}"
|
||||
|
||||
CONFIGURE_COMMAND ${CMAKE_COMMAND} <SOURCE_DIR>
|
||||
-DCMAKE_INSTALL_PREFIX=${install_prefix}
|
||||
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
|
||||
${ARGS_OPTS}
|
||||
BUILD_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}"
|
||||
INSTALL_COMMAND ${CMAKE_COMMAND} --build "${CMAKE_BINARY_DIR}/${_NAME}" --target install
|
||||
)
|
||||
endfunction ()
|
||||
|
||||
include_directories(${CMAKE_BINARY_DIR}/external/include)
|
||||
link_directories(${CMAKE_BINARY_DIR}/external/lib)
|
||||
|
||||
if (THEORIES)
|
||||
add_subdirectory(dependencies/dyncall/ EXCLUDE_FROM_ALL)
|
||||
include_directories(dependencies/dyncall/dyncall/)
|
||||
endif ()
|
||||
|
||||
include_directories(SYSTEM
|
||||
/usr/local/include
|
||||
/usr/include/GNUstep
|
||||
cr_add_subproject (nanomsg
|
||||
PATH dependencies/nanomsg-patched
|
||||
OPTS "-DNN_TESTS=OFF"
|
||||
CMAKE
|
||||
IF MSVC
|
||||
)
|
||||
cr_add_subproject (nanomsg
|
||||
PATH dependencies/nanomsg-patched
|
||||
AUTOTOOLS
|
||||
PARALLELIZE
|
||||
IF NOT MSVC
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
add_cmake_subproject(nanomsg
|
||||
PATH dependencies/nanomsg-patched
|
||||
OPTS "-DNN_TESTS=OFF")
|
||||
|
||||
else ()
|
||||
|
||||
include(ExternalProject)
|
||||
|
||||
externalproject_add(
|
||||
nanomsg
|
||||
SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/dependencies/nanomsg-patched"
|
||||
PREFIX "${CMAKE_CURRENT_BINARY_DIR}/nanomsg-patched"
|
||||
|
||||
UPDATE_COMMAND <SOURCE_DIR>/autogen.sh
|
||||
CONFIGURE_COMMAND <SOURCE_DIR>/configure --prefix=<INSTALL_DIR>
|
||||
BUILD_COMMAND make -j4
|
||||
INSTALL_COMMAND make install
|
||||
)
|
||||
|
||||
externalproject_get_property(nanomsg install_dir)
|
||||
set(NANOMSG_INSTALL_DIR "${install_dir}")
|
||||
|
||||
include_directories(${CMAKE_CURRENT_BINARY_DIR}/nanomsg-patched/include/)
|
||||
link_directories(${CMAKE_CURRENT_BINARY_DIR}/nanomsg-patched/lib/)
|
||||
|
||||
endif ()
|
||||
cr_add_subproject (wingetopt PATH dependencies/wingetopt CMAKE IF MSVC)
|
||||
|
||||
include_directories(
|
||||
dependencies/libcsptr/include/
|
||||
dependencies/valgrind/include/
|
||||
dependencies/klib/
|
||||
dependencies/nanopb/
|
||||
)
|
||||
|
||||
if (MSVC)
|
||||
add_subdirectory(dependencies/wingetopt/ EXCLUDE_FROM_ALL)
|
||||
include_directories(dependencies/wingetopt/src/)
|
||||
endif ()
|
||||
|
||||
# Check for C++11
|
||||
|
||||
option(LANG_CXX "Turn on C++ support" ON)
|
||||
if (LANG_CXX)
|
||||
enable_language(CXX)
|
||||
endif ()
|
||||
|
||||
if (NOT MSVC AND CMAKE_CXX_COMPILER_WORKS)
|
||||
include(CheckCXXCompilerFlag)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
|
||||
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
|
||||
|
||||
if(COMPILER_SUPPORTS_CXX11)
|
||||
set(CXX11_FLAG "-std=c++11")
|
||||
elseif(COMPILER_SUPPORTS_CXX0X)
|
||||
set(CXX11_FLAG "-std=c++0x")
|
||||
else()
|
||||
message(FATAL_ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support.")
|
||||
endif()
|
||||
endif()
|
||||
|
||||
# Project setup & environment variables
|
||||
|
||||
set(PROJECT_VERSION "2.2.0")
|
||||
set(PROJECT_SOVERSION 2)
|
||||
set(LOCALEDIR_REL "share/locale")
|
||||
set(LOCALEDIR "${CMAKE_INSTALL_PREFIX}/${LOCALEDIR_REL}")
|
||||
set(GettextTranslate_ALL 1)
|
||||
set(GettextTranslate_GMO_BINARY 1)
|
||||
|
||||
add_definitions(-DCRITERION_BUILDING_DLL=1)
|
||||
add_definitions(-DPB_ENABLE_MALLOC=1)
|
||||
|
||||
set(CMAKE_C_FLAGS_DEFAULT "${CMAKE_C_FLAGS}")
|
||||
set(CMAKE_CXX_FLAGS_DEFAULT "${CMAKE_CXX_FLAGS}")
|
||||
|
||||
if (NOT MSVC)
|
||||
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99")
|
||||
if (CMAKE_CXX_COMPILER_WORKS)
|
||||
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -g ${CXX11_FLAG}")
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
|
||||
endif ()
|
||||
|
||||
if (WIN32 AND NOT MSVC)
|
||||
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
|
||||
endif()
|
||||
|
||||
# Compilation options
|
||||
|
||||
option(MINGW_DEFINE_OFF_T "Define off_t and off64_t ourselves before including io.h" OFF)
|
||||
|
||||
# Setup coveralls
|
||||
|
||||
option(COVERALLS "Turn on coveralls support" OFF)
|
||||
option(COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
|
||||
option(DEV_BUILD "Compile in developer mode" OFF)
|
||||
option(CTESTS "Turn on the samples and test" ${DEV_BUILD})
|
||||
|
||||
if (DEV_BUILD)
|
||||
set(ENABLE_VALGRIND_ERRORS 1)
|
||||
endif ()
|
||||
# Coverage
|
||||
|
||||
if (COVERALLS)
|
||||
include(Coveralls)
|
||||
coveralls_turn_on_coverage()
|
||||
endif()
|
||||
|
||||
# Find dependencies
|
||||
# I18N
|
||||
|
||||
option(I18N "Turn on internationalization" ON)
|
||||
|
||||
if (I18N)
|
||||
find_package(Gettext)
|
||||
find_package(Libintl)
|
||||
if (GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
|
||||
include(GettextTranslate)
|
||||
add_subdirectory(po)
|
||||
set(ENABLE_NLS 1)
|
||||
endif ()
|
||||
if (I18N AND GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
|
||||
include(GettextTranslate)
|
||||
add_subdirectory(po)
|
||||
endif ()
|
||||
|
||||
include(CheckLibraryExists)
|
||||
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
|
||||
|
||||
find_package(PCRE)
|
||||
|
||||
# List sources and headers
|
||||
|
||||
set(SOURCE_FILES
|
||||
src/core/abort.c
|
||||
src/core/abort.h
|
||||
src/core/report.c
|
||||
src/core/report.h
|
||||
src/core/runner.c
|
||||
src/core/runner.h
|
||||
src/core/runner_coroutine.c
|
||||
src/core/runner_coroutine.h
|
||||
src/core/coroutine.h
|
||||
src/core/worker.c
|
||||
src/core/worker.h
|
||||
src/core/stats.c
|
||||
src/core/stats.h
|
||||
src/core/ordered-set.c
|
||||
src/core/test.c
|
||||
src/core/client.c
|
||||
src/core/client.h
|
||||
src/compat/internal.h
|
||||
src/compat/pipe.c
|
||||
src/compat/pipe.h
|
||||
src/compat/pipe-internal.h
|
||||
src/compat/section.c
|
||||
src/compat/section.h
|
||||
src/compat/process.c
|
||||
src/compat/process.h
|
||||
src/compat/basename.c
|
||||
src/compat/basename.h
|
||||
src/compat/mockfile.c
|
||||
src/compat/time.c
|
||||
src/compat/time.h
|
||||
src/compat/posix.h
|
||||
src/compat/alloc.c
|
||||
src/compat/alloc.h
|
||||
src/compat/processor.c
|
||||
src/compat/processor.h
|
||||
src/compat/kill.c
|
||||
src/compat/kill.h
|
||||
src/io/redirect.c
|
||||
src/io/event.c
|
||||
src/io/event.h
|
||||
src/io/asprintf.c
|
||||
src/io/file.c
|
||||
src/io/output.c
|
||||
src/io/output.h
|
||||
src/io/tap.c
|
||||
src/io/xml.c
|
||||
src/io/json.c
|
||||
src/log/logging.c
|
||||
src/log/normal.c
|
||||
src/string/i18n.c
|
||||
src/string/i18n.h
|
||||
src/entry/options.c
|
||||
src/entry/params.c
|
||||
src/entry/entry.c
|
||||
src/protocol/criterion.pb.c
|
||||
src/protocol/criterion.pb.h
|
||||
src/protocol/protocol.c
|
||||
src/protocol/messages.c
|
||||
src/protocol/messages.h
|
||||
src/protocol/connect.c
|
||||
src/protocol/connect.h
|
||||
src/common.h
|
||||
src/config.h
|
||||
|
||||
dependencies/nanopb/pb_common.c
|
||||
dependencies/nanopb/pb_common.h
|
||||
dependencies/nanopb/pb_encode.c
|
||||
dependencies/nanopb/pb_encode.h
|
||||
dependencies/nanopb/pb_decode.c
|
||||
dependencies/nanopb/pb_decode.h
|
||||
)
|
||||
|
||||
if (THEORIES)
|
||||
set (SOURCE_FILES ${SOURCE_FILES}
|
||||
src/core/theories.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (PCRE_FOUND)
|
||||
set (SOURCE_FILES ${SOURCE_FILES}
|
||||
src/string/extmatch.c
|
||||
src/string/extmatch.h
|
||||
)
|
||||
set(HAVE_PCRE 1)
|
||||
endif ()
|
||||
|
||||
set(INTERFACE_FILES
|
||||
include/criterion/assert.h
|
||||
include/criterion/abort.h
|
||||
include/criterion/criterion.h
|
||||
include/criterion/event.h
|
||||
include/criterion/hooks.h
|
||||
include/criterion/logging.h
|
||||
include/criterion/types.h
|
||||
include/criterion/options.h
|
||||
include/criterion/stats.h
|
||||
include/criterion/alloc.h
|
||||
include/criterion/parameterized.h
|
||||
include/criterion/redirect.h
|
||||
include/criterion/output.h
|
||||
include/criterion/internal/assert.h
|
||||
include/criterion/internal/test.h
|
||||
include/criterion/internal/common.h
|
||||
include/criterion/internal/ordered-set.h
|
||||
include/criterion/internal/asprintf-compat.h
|
||||
include/criterion/internal/designated-initializer-compat.h
|
||||
include/criterion/internal/preprocess.h
|
||||
include/criterion/internal/parameterized.h
|
||||
include/criterion/internal/stdio_filebuf.hxx
|
||||
include/criterion/internal/stream.hxx
|
||||
include/criterion/internal/hooks.h
|
||||
include/criterion/internal/redirect.h
|
||||
include/criterion/internal/stdio_filebuf.hxx
|
||||
)
|
||||
|
||||
if (THEORIES)
|
||||
set(INTERFACE_FILES ${INTERFACE_FILES}
|
||||
include/criterion/theories.h
|
||||
include/criterion/internal/theories.h
|
||||
)
|
||||
endif()
|
||||
|
||||
# Generate the configure file
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h"
|
||||
)
|
||||
# Project
|
||||
|
||||
include_directories(include src)
|
||||
add_library(criterion SHARED ${SOURCE_FILES} ${INTERFACE_FILES})
|
||||
add_subdirectory (src)
|
||||
|
||||
set_target_properties(criterion PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_SOVERSION}
|
||||
cr_add_library(criterion SHARED
|
||||
SOURCES ${SOURCE_FILES}
|
||||
HEADERS ${INTERFACE_FILES}
|
||||
COMPONENT dev
|
||||
PROPERTIES
|
||||
VERSION ${PROJECT_VERSION}
|
||||
SOVERSION ${PROJECT_SOVERSION}
|
||||
)
|
||||
|
||||
add_dependencies(criterion nanomsg)
|
||||
target_link_libraries(criterion csptr)
|
||||
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)
|
||||
|
||||
if (WIN32)
|
||||
target_link_libraries(criterion ${CMAKE_BINARY_DIR}/external/lib/nanomsg.lib)
|
||||
else ()
|
||||
target_link_libraries(criterion ${CMAKE_CURRENT_BINARY_DIR}/nanomsg-patched/lib/libnanomsg.a)
|
||||
endif ()
|
||||
cr_link_libraries(criterion pthread IF NOT WIN32)
|
||||
cr_link_libraries(criterion anl IF NOT WIN32 AND NOT APPLE)
|
||||
cr_link_libraries(criterion rt IF HAVE_CLOCK_GETTIME)
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(criterion csptr pthread)
|
||||
if (NOT APPLE)
|
||||
target_link_libraries(criterion csptr anl)
|
||||
endif ()
|
||||
endif ()
|
||||
|
||||
if (THEORIES)
|
||||
target_link_libraries(criterion dyncall_s)
|
||||
endif ()
|
||||
|
||||
if (MSVC)
|
||||
target_link_libraries(criterion wingetopt)
|
||||
endif ()
|
||||
|
||||
if (NOT WIN32)
|
||||
target_link_libraries(criterion pthread)
|
||||
endif ()
|
||||
|
||||
if (HAVE_CLOCK_GETTIME)
|
||||
target_link_libraries(criterion rt)
|
||||
endif()
|
||||
|
||||
if (PCRE_FOUND)
|
||||
target_link_libraries(criterion ${PCRE_LIBRARIES})
|
||||
endif()
|
||||
|
||||
if (LIBINTL_LIB_FOUND)
|
||||
target_link_libraries(criterion ${LIBINTL_LIBRARIES})
|
||||
include_directories(${LIBINTL_INCLUDE_DIR})
|
||||
endif()
|
||||
cr_link_package(criterion PCRE)
|
||||
cr_link_package(criterion LIBINTL)
|
||||
|
||||
if (COVERALLS)
|
||||
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
|
||||
endif()
|
||||
|
||||
foreach (F ${INTERFACE_FILES})
|
||||
get_filename_component(DEST "${F}" PATH)
|
||||
install(FILES "${F}" DESTINATION "${DEST}" COMPONENT dev)
|
||||
endforeach ()
|
||||
|
||||
install(TARGETS criterion
|
||||
RUNTIME DESTINATION bin
|
||||
LIBRARY DESTINATION lib
|
||||
ARCHIVE DESTINATION lib COMPONENT dev
|
||||
)
|
||||
|
||||
add_custom_target(criterion_tests)
|
||||
|
||||
add_custom_target(gcov
|
||||
add_custom_target(gcov
|
||||
"${CMAKE_COMMAND}"
|
||||
-DSOURCE_FILES="${SOURCE_FILES}"
|
||||
-DCOV_PATH="${CMAKE_CURRENT_BINARY_DIR}"
|
||||
-P "${CMAKE_MODULE_PATH}/Gcov.cmake"
|
||||
)
|
||||
)
|
||||
endif()
|
||||
|
||||
if (CTESTS)
|
||||
enable_testing()
|
||||
add_subdirectory(samples)
|
||||
add_subdirectory(test)
|
||||
enable_testing()
|
||||
add_custom_target(criterion_tests)
|
||||
add_subdirectory(samples)
|
||||
add_subdirectory(test)
|
||||
endif ()
|
||||
|
||||
# Add toolchain patch number for incremental deb builds
|
||||
set(PROJECT_VERSION "${PROJECT_VERSION}-2")
|
||||
|
||||
include (PackageConfig)
|
||||
|
||||
option(UPLOAD_DEB "Upload package to launchpad" OFF)
|
||||
|
||||
if (UNIX AND UPLOAD_DEB)
|
||||
include (DebConfig)
|
||||
if (UPLOAD_DEB)
|
||||
include (DebUpload)
|
||||
endif ()
|
||||
|
|
137
src/CMakeLists.txt
Normal file
137
src/CMakeLists.txt
Normal file
|
@ -0,0 +1,137 @@
|
|||
# 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.
|
||||
|
||||
# List sources and headers
|
||||
|
||||
set(SOURCE_FILES
|
||||
src/core/abort.c
|
||||
src/core/abort.h
|
||||
src/core/report.c
|
||||
src/core/report.h
|
||||
src/core/runner.c
|
||||
src/core/runner.h
|
||||
src/core/runner_coroutine.c
|
||||
src/core/runner_coroutine.h
|
||||
src/core/coroutine.h
|
||||
src/core/worker.c
|
||||
src/core/worker.h
|
||||
src/core/stats.c
|
||||
src/core/stats.h
|
||||
src/core/ordered-set.c
|
||||
src/core/test.c
|
||||
src/core/client.c
|
||||
src/core/client.h
|
||||
src/compat/internal.h
|
||||
src/compat/pipe.c
|
||||
src/compat/pipe.h
|
||||
src/compat/pipe-internal.h
|
||||
src/compat/section.c
|
||||
src/compat/section.h
|
||||
src/compat/process.c
|
||||
src/compat/process.h
|
||||
src/compat/basename.c
|
||||
src/compat/basename.h
|
||||
src/compat/mockfile.c
|
||||
src/compat/time.c
|
||||
src/compat/time.h
|
||||
src/compat/posix.h
|
||||
src/compat/alloc.c
|
||||
src/compat/alloc.h
|
||||
src/compat/processor.c
|
||||
src/compat/processor.h
|
||||
src/compat/kill.c
|
||||
src/compat/kill.h
|
||||
src/io/redirect.c
|
||||
src/io/event.c
|
||||
src/io/event.h
|
||||
src/io/asprintf.c
|
||||
src/io/file.c
|
||||
src/io/output.c
|
||||
src/io/output.h
|
||||
src/io/tap.c
|
||||
src/io/xml.c
|
||||
src/io/json.c
|
||||
src/log/logging.c
|
||||
src/log/normal.c
|
||||
src/string/i18n.c
|
||||
src/string/i18n.h
|
||||
src/entry/options.c
|
||||
src/entry/params.c
|
||||
src/entry/entry.c
|
||||
src/protocol/criterion.pb.c
|
||||
src/protocol/criterion.pb.h
|
||||
src/protocol/protocol.c
|
||||
src/protocol/messages.c
|
||||
src/protocol/messages.h
|
||||
src/protocol/connect.c
|
||||
src/protocol/connect.h
|
||||
src/common.h
|
||||
src/config.h
|
||||
|
||||
dependencies/nanopb/pb_common.c
|
||||
dependencies/nanopb/pb_common.h
|
||||
dependencies/nanopb/pb_encode.c
|
||||
dependencies/nanopb/pb_encode.h
|
||||
dependencies/nanopb/pb_decode.c
|
||||
dependencies/nanopb/pb_decode.h
|
||||
)
|
||||
|
||||
if (THEORIES)
|
||||
set (SOURCE_FILES ${SOURCE_FILES}
|
||||
src/core/theories.c
|
||||
)
|
||||
endif ()
|
||||
|
||||
if (PCRE_FOUND)
|
||||
set (SOURCE_FILES ${SOURCE_FILES}
|
||||
src/string/extmatch.c
|
||||
src/string/extmatch.h
|
||||
)
|
||||
endif ()
|
||||
|
||||
set(INTERFACE_FILES
|
||||
include/criterion/assert.h
|
||||
include/criterion/abort.h
|
||||
include/criterion/criterion.h
|
||||
include/criterion/event.h
|
||||
include/criterion/hooks.h
|
||||
include/criterion/logging.h
|
||||
include/criterion/types.h
|
||||
include/criterion/options.h
|
||||
include/criterion/stats.h
|
||||
include/criterion/alloc.h
|
||||
include/criterion/parameterized.h
|
||||
include/criterion/redirect.h
|
||||
include/criterion/output.h
|
||||
include/criterion/internal/assert.h
|
||||
include/criterion/internal/test.h
|
||||
include/criterion/internal/common.h
|
||||
include/criterion/internal/ordered-set.h
|
||||
include/criterion/internal/asprintf-compat.h
|
||||
include/criterion/internal/designated-initializer-compat.h
|
||||
include/criterion/internal/preprocess.h
|
||||
include/criterion/internal/parameterized.h
|
||||
include/criterion/internal/stdio_filebuf.hxx
|
||||
include/criterion/internal/stream.hxx
|
||||
include/criterion/internal/hooks.h
|
||||
include/criterion/internal/redirect.h
|
||||
include/criterion/internal/stdio_filebuf.hxx
|
||||
)
|
||||
|
||||
if (THEORIES)
|
||||
set(INTERFACE_FILES ${INTERFACE_FILES}
|
||||
include/criterion/theories.h
|
||||
include/criterion/internal/theories.h
|
||||
)
|
||||
endif()
|
||||
|
||||
# Generate the configure file
|
||||
|
||||
configure_file(
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/config.h.in"
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/config.h"
|
||||
)
|
||||
|
||||
set (SOURCE_FILES ${SOURCE_FILES} PARENT_SCOPE)
|
||||
set (INTERFACE_FILES ${INTERFACE_FILES} PARENT_SCOPE)
|
Loading…
Add table
Reference in a new issue