2015-07-29 17:22:49 +02:00
|
|
|
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)
|
2015-07-28 22:44:28 +02:00
|
|
|
|
2015-09-04 03:03:40 +02:00
|
|
|
set(MODULE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.cmake/Modules")
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${MODULE_DIR})
|
2015-09-04 02:47:06 +02:00
|
|
|
set(LIBCSPTR_DISABLE_TESTS ON)
|
2015-09-04 03:32:19 +02:00
|
|
|
set(LIBCSPTR_DISABLE_COVERALLS ON)
|
2015-07-30 13:09:18 +02:00
|
|
|
|
2015-09-04 03:03:40 +02:00
|
|
|
include(Submodules)
|
2015-10-03 01:08:15 +03:00
|
|
|
include(Capabilities)
|
2015-09-04 03:03:40 +02:00
|
|
|
|
2015-09-06 07:23:21 -07:00
|
|
|
if (MSVC)
|
|
|
|
add_definitions(-D_CRT_SECURE_NO_WARNINGS=1)
|
|
|
|
endif ()
|
|
|
|
|
2015-09-04 02:47:06 +02:00
|
|
|
add_subdirectory(dependencies/libcsptr/ EXCLUDE_FROM_ALL)
|
|
|
|
add_subdirectory(dependencies/dyncall/ EXCLUDE_FROM_ALL)
|
|
|
|
|
2015-09-28 12:26:40 +02:00
|
|
|
include_directories(SYSTEM /usr/local/include)
|
|
|
|
|
2015-09-04 02:47:06 +02:00
|
|
|
include_directories(
|
|
|
|
dependencies/libcsptr/include/
|
|
|
|
dependencies/dyncall/dyncall/
|
2015-09-26 00:22:21 +02:00
|
|
|
dependencies/valgrind/include/
|
2015-09-04 02:47:06 +02:00
|
|
|
)
|
|
|
|
|
2015-09-05 23:22:47 +02:00
|
|
|
if (MSVC)
|
|
|
|
add_subdirectory(dependencies/wingetopt/ EXCLUDE_FROM_ALL)
|
|
|
|
include_directories(dependencies/wingetopt/src/)
|
|
|
|
endif ()
|
|
|
|
|
2015-07-30 13:09:18 +02:00
|
|
|
# Project setup & environment variables
|
|
|
|
|
2015-09-21 22:30:36 +02:00
|
|
|
set(PROJECT_VERSION "2.1.0")
|
2015-07-28 22:44:28 +02:00
|
|
|
set(LOCALEDIR ${CMAKE_INSTALL_PREFIX}/share/locale)
|
2015-08-05 13:13:25 +02:00
|
|
|
set(GettextTranslate_ALL 1)
|
|
|
|
set(GettextTranslate_GMO_BINARY 1)
|
2015-07-28 19:03:46 +02:00
|
|
|
|
2015-09-06 00:17:03 +02:00
|
|
|
add_definitions(-DCRITERION_BUILDING_DLL=1)
|
2015-09-04 02:47:06 +02:00
|
|
|
|
2015-09-05 15:47:47 -07:00
|
|
|
if (NOT MSVC)
|
|
|
|
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Wextra -Werror -g -std=gnu99")
|
2015-10-01 15:05:22 +02:00
|
|
|
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -Werror -g -std=c++11")
|
2015-09-05 15:47:47 -07:00
|
|
|
endif ()
|
2015-08-05 09:45:54 +02:00
|
|
|
|
2015-09-05 23:48:09 +02:00
|
|
|
if (MSVC)
|
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} /SAFESEH:NO")
|
|
|
|
endif ()
|
2015-08-05 09:45:54 +02:00
|
|
|
|
2015-09-05 15:47:47 -07:00
|
|
|
if (WIN32 AND NOT MSVC)
|
2015-08-05 09:45:54 +02:00
|
|
|
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,-no-undefined")
|
|
|
|
endif()
|
2015-07-28 19:03:46 +02:00
|
|
|
|
2015-07-30 13:09:18 +02:00
|
|
|
# Setup coveralls
|
|
|
|
|
|
|
|
option(COVERALLS "Turn on coveralls support" OFF)
|
|
|
|
option(COVERALLS_UPLOAD "Upload the generated coveralls json" ON)
|
2015-09-26 17:02:28 +02:00
|
|
|
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 ()
|
2015-07-30 13:09:18 +02:00
|
|
|
|
|
|
|
if (COVERALLS)
|
|
|
|
include(Coveralls)
|
|
|
|
coveralls_turn_on_coverage()
|
|
|
|
endif()
|
|
|
|
|
|
|
|
# Find dependencies
|
|
|
|
|
2015-07-28 22:44:28 +02:00
|
|
|
find_package(Gettext)
|
2015-07-31 08:02:09 +02:00
|
|
|
find_package(Libintl)
|
2015-07-31 12:01:02 +02:00
|
|
|
if (GETTEXT_FOUND AND LIBINTL_LIB_FOUND)
|
2015-07-28 22:44:28 +02:00
|
|
|
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)
|
|
|
|
|
2015-07-30 13:09:18 +02:00
|
|
|
# List sources and headers
|
|
|
|
|
2015-07-28 19:03:46 +02:00
|
|
|
set(SOURCE_FILES
|
2015-10-01 15:05:22 +02:00
|
|
|
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
|
2015-09-24 16:08:58 +02:00
|
|
|
src/core/runner_coroutine.c
|
|
|
|
src/core/runner_coroutine.h
|
2015-10-02 14:45:28 +02:00
|
|
|
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
|
2015-10-02 14:45:28 +02:00
|
|
|
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
|
2015-09-22 23:21:51 +02:00
|
|
|
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
|
2015-10-02 14:45:28 +02:00
|
|
|
src/common.h
|
|
|
|
src/config.h
|
2015-07-28 19:03:46 +02:00
|
|
|
)
|
|
|
|
|
2015-07-31 07:44:32 +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
|
2015-07-31 07:44:32 +02:00
|
|
|
)
|
2015-07-31 11:54:10 +02:00
|
|
|
set(HAVE_PCRE 1)
|
2015-07-31 07:44:32 +02:00
|
|
|
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
|
2015-09-08 18:46:04 +02:00
|
|
|
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
|
2015-10-02 14:45:28 +02:00
|
|
|
include/criterion/parameterized.h
|
|
|
|
include/criterion/redirect.h
|
2015-07-28 19:03:46 +02:00
|
|
|
)
|
|
|
|
|
2015-07-31 12:01:02 +02:00
|
|
|
# Generate the configure file
|
|
|
|
|
|
|
|
configure_file(
|
2015-09-04 02:47:06 +02:00
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h.in"
|
|
|
|
"${CMAKE_CURRENT_SOURCE_DIR}/src/config.h"
|
2015-07-31 12:01:02 +02:00
|
|
|
)
|
|
|
|
|
2015-09-04 02:47:06 +02:00
|
|
|
include_directories(include src)
|
2015-07-29 18:22:47 +02:00
|
|
|
add_library(criterion SHARED ${SOURCE_FILES} ${INTERFACE_FILES})
|
2015-09-04 02:47:06 +02:00
|
|
|
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()
|
|
|
|
|
2015-07-31 12:01:02 +02:00
|
|
|
if (LIBINTL_LIB_FOUND)
|
2015-07-31 08:02:09 +02:00
|
|
|
target_link_libraries(criterion ${LIBINTL_LIBRARIES})
|
2015-09-22 01:12:32 +02:00
|
|
|
include_directories(${LIBINTL_INCLUDE_DIR})
|
2015-07-31 08:02:09 +02:00
|
|
|
endif()
|
|
|
|
|
2015-07-30 13:09:18 +02:00
|
|
|
if (COVERALLS)
|
|
|
|
coveralls_setup("${SOURCE_FILES}" ${COVERALLS_UPLOAD})
|
|
|
|
endif()
|
|
|
|
|
2015-07-28 22:44:28 +02:00
|
|
|
install(FILES ${INTERFACE_FILES} DESTINATION include/criterion)
|
2015-07-28 19:03:46 +02:00
|
|
|
install(TARGETS criterion
|
2015-08-04 17:07:29 +02:00
|
|
|
RUNTIME DESTINATION bin
|
2015-07-28 19:03:46 +02:00
|
|
|
LIBRARY DESTINATION lib
|
2015-07-30 20:30:01 +02:00
|
|
|
ARCHIVE DESTINATION lib
|
2015-07-28 19:03:46 +02:00
|
|
|
)
|
|
|
|
|
2015-09-09 19:19:58 +02:00
|
|
|
add_custom_target(criterion_tests)
|
|
|
|
|
2015-09-04 04:52:44 +02:00
|
|
|
add_custom_target(gcov
|
2015-09-04 05:11:06 +02:00
|
|
|
"${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)
|
2015-08-21 00:26:51 +02:00
|
|
|
enable_testing()
|
|
|
|
add_subdirectory(samples)
|
2015-08-21 06:30:20 +02:00
|
|
|
add_subdirectory(test)
|
2015-09-21 23:26:47 +02:00
|
|
|
endif ()
|