Criterion/CMakeLists.txt

224 lines
5 KiB
Text
Raw Permalink Normal View History

cmake_minimum_required(VERSION 2.8)
2015-07-28 19:03:46 +02:00
2015-09-07 01:15:31 +02:00
project(Criterion C CXX)
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)
include(Submodules)
include(Capabilities)
if (MSVC)
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
endif ()
add_subdirectory(dependencies/libcsptr/ EXCLUDE_FROM_ALL)
add_subdirectory(dependencies/dyncall/ EXCLUDE_FROM_ALL)
include_directories(SYSTEM /usr/local/include)
include_directories(
dependencies/libcsptr/include/
dependencies/dyncall/dyncall/
dependencies/valgrind/include/
)
2015-09-05 23:22:47 +02:00
if (MSVC)
add_subdirectory(dependencies/wingetopt/ EXCLUDE_FROM_ALL)
include_directories(dependencies/wingetopt/src/)
endif ()
# Project setup & environment variables
set(PROJECT_VERSION "2.1.0")
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
set(GettextTranslate_ALL 1)
set(GettextTranslate_GMO_BINARY 1)
2015-07-28 19:03:46 +02:00
add_definitions(-DCRITERION_BUILDING_DLL=1)
2015-09-05 15:47:47 -07:00
if (NOT MSVC)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -g -std=c++11")
2015-09-05 15:47:47 -07:00
endif ()
2015-09-05 23:48:09 +02:00
if (MSVC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
endif ()
2015-09-05 15:47:47 -07:00
if (WIN32 AND NOT MSVC)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
endif()
2015-07-28 19:03:46 +02:00
# 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 ()
if (COVERALLS)
include(Coveralls)
coveralls_turn_on_coverage()
endif()
# Find dependencies
find_package(Gettext)
find_package(Libintl)
if (GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
include(GettextTranslate)
add_subdirectory(po)
set(ENABLE_NLS 1)
endif ()
2015-07-28 19:03:46 +02:00
include(CheckLibraryExists)
CHECK_LIBRARY_EXISTS(rt clock_gettime "time.h" HAVE_CLOCK_GETTIME)
find_package(PCRE)
# List sources and headers
2015-07-28 19:03:46 +02:00
set(SOURCE_FILES
src/core/wrappers/wrap.c
src/core/wrappers/wrap.cc
2015-09-16 21:18:58 +02:00
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
2015-09-16 21:18:58 +02:00
src/core/worker.c
src/core/worker.h
src/core/stats.c
src/core/stats.h
src/core/ordered-set.c
src/core/theories.c
2015-09-16 21:00:15 +02:00
src/compat/internal.h
src/compat/pipe.c
src/compat/pipe.h
src/compat/pipe-internal.h
2015-09-16 21:00:15 +02:00
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
2015-09-16 21:18:58 +02:00
src/compat/time.c
src/compat/time.h
2015-09-16 21:00:15 +02:00
src/compat/posix.h
2015-09-19 18:08:37 +02:00
src/compat/alloc.c
src/compat/alloc.h
src/compat/processor.c
src/compat/processor.h
2015-09-16 21:18:58 +02:00
src/io/redirect.c
src/io/event.c
src/io/event.h
src/io/asprintf.c
src/io/file.c
2015-07-28 19:03:46 +02:00
src/log/logging.c
src/log/tap.c
src/log/normal.c
2015-10-05 16:22:55 +02:00
src/log/xml.c
2015-09-16 21:18:58 +02:00
src/string/i18n.c
src/string/i18n.h
src/entry/options.c
src/entry/main.c
src/entry/entry.c
src/common.h
src/config.h
2015-07-28 19:03:46 +02:00
)
if (PCRE_FOUND)
set (SOURCE_FILES ${SOURCE_FILES}
2015-09-16 21:18:58 +02:00
src/string/extmatch.c
src/string/extmatch.h
)
set(HAVE_PCRE 1)
endif ()
2015-07-28 19:03:46 +02:00
set(INTERFACE_FILES
include/criterion/assert.h
include/criterion/abort.h
include/criterion/common.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/ordered-set.h
include/criterion/stats.h
2015-09-03 06:38:44 +02:00
include/criterion/theories.h
include/criterion/asprintf-compat.h
2015-09-09 03:36:41 +02:00
include/criterion/designated-initializer-compat.h
include/criterion/preprocess.h
2015-09-19 18:08:37 +02:00
include/criterion/alloc.h
include/criterion/parameterized.h
include/criterion/redirect.h
2015-07-28 19:03:46 +02:00
)
# Generate the configure file
configure_file(
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in"
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h"
)
include_directories(include src)
2015-07-29 18:22:47 +02:00
add_library(criterion SHARED ${SOURCE_FILES} ${INTERFACE_FILES})
target_link_libraries(criterion csptr dyncall_s)
2015-07-28 19:03:46 +02:00
2015-09-05 23:42:22 +02:00
if (MSVC)
target_link_libraries(criterion wingetopt)
endif ()
2015-07-28 19:03:46 +02:00
if (HAVE_CLOCK_GETTIME)
target_link_libraries(criterion rt)
endif()
if (PCRE_FOUND)
2015-07-29 18:22:47 +02:00
target_link_libraries(criterion ${PCRE_LIBRARIES})
2015-07-28 19:03:46 +02:00
endif()
if (LIBINTL_LIB_FOUND)
target_link_libraries(criterion ${LIBINTL_LIBRARIES})
include_directories(${LIBINTL_INCLUDE_DIR})
endif()
if (COVERALLS)
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
endif()
install(FILES ${INTERFACE_FILES} DESTINATION include/criterion)
2015-07-28 19:03:46 +02:00
install(TARGETS criterion
RUNTIME DESTINATION bin
2015-07-28 19:03:46 +02:00
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
2015-07-28 19:03:46 +02:00
)
add_custom_target(criterion_tests)
2015-09-04 04:52:44 +02:00
add_custom_target(gcov
"${CMAKE_COMMAND}"
-DSOURCE_FILES="${SOURCE_FILES}"
-DCOV_PATH="${CMAKE_CURRENT_BINARY_DIR}"
-P "${CMAKE_MODULE_PATH}/Gcov.cmake"
2015-09-04 04:52:44 +02:00
)
2015-09-22 00:16:45 +02:00
if (CTESTS)
enable_testing()
add_subdirectory(samples)
2015-08-21 06:30:20 +02:00
add_subdirectory(test)
endif ()