-
Notifications
You must be signed in to change notification settings - Fork 211
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor/cmake buildsystem configuration #314
base: master
Are you sure you want to change the base?
Changes from all commits
ffc0213
2e42216
f36f57f
dc1fba6
df85211
5d7f423
82ab715
6944475
e3401d5
7a34119
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -77,12 +77,6 @@ set(PROJECT_VERSION "${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}.${PROJECT | |
# Provides install directory variables as defined by the GNU Coding Standards. | ||
include(GNUInstallDirs) | ||
|
||
############################################################################### | ||
# Follow ISO C99 standard | ||
set(CMAKE_C_STANDARD 99) | ||
set(CMAKE_C_STANDARD_REQUIRED ON) | ||
set(CMAKE_C_EXTENSIONS ON) # Use GNU extensions and POSIX standard | ||
|
||
############################################################################### | ||
# Option | ||
option(CHECK_ENABLE_TESTS | ||
|
@@ -108,22 +102,6 @@ if(CHECK_ENABLE_TIMEOUT_TESTS) | |
else(CHECK_ENABLE_TIMEOUT_TESTS) | ||
add_definitions(-DTIMEOUT_TESTS_ENABLED=0) | ||
endif(CHECK_ENABLE_TIMEOUT_TESTS) | ||
############################################################################### | ||
# Check system and architecture | ||
if(WIN32) | ||
if(MSVC60) | ||
set(WINVER 0x0400) | ||
else() | ||
set(WINVER 0x0600) | ||
endif() | ||
set(_WIN32_WINNT ${WINVER}) | ||
endif(WIN32) | ||
|
||
if(MSVC) | ||
add_definitions(-D_CRT_SECURE_NO_DEPRECATE) | ||
add_definitions(-D_CRT_SECURE_NO_WARNINGS) | ||
add_definitions(-D_CRT_NONSTDC_NO_WARNINGS) | ||
endif(MSVC) | ||
|
||
############################################################################### | ||
include(CheckCSourceCompiles) | ||
|
@@ -167,7 +145,9 @@ ck_check_include_file("unistd.h" HAVE_UNISTD_H) | |
ck_check_include_file("pthread.h" HAVE_PTHREAD) | ||
|
||
# check if we have windows.h on native windows environments | ||
ck_check_include_file("windows.h" HAVE_WINDOWS_H) | ||
IF(WIN32) | ||
ck_check_include_file("windows.h" HAVE_WINDOWS_H) | ||
ENDIF() | ||
|
||
############################################################################### | ||
# Check functions | ||
|
@@ -244,14 +224,22 @@ if(HAVE_REGEX_H AND HAVE_REGCOMP AND HAVE_REGEXEC) | |
set(ENABLE_REGEX 1) | ||
endif() | ||
|
||
if (HAVE_PTHREAD) | ||
check_c_compiler_flag("-pthread" HAVE_PTHREADS_FLAG) | ||
if (HAVE_PTHREADS_FLAG) | ||
add_definitions("-pthread") | ||
add_link_options("-pthread") | ||
endif() | ||
endif() | ||
INCLUDE(FindThreads) | ||
|
||
SET(THREADS_PREFER_PTHREAD_FLAG ON) | ||
MESSAGE(STATUS "Prefer -pthread: ${THREADS_PREFER_PTHREAD_FLAG}") | ||
|
||
FIND_PACKAGE(Threads | ||
REQUIRED | ||
) | ||
|
||
IF(Threads_FOUND AND CMAKE_USE_PTHREADS_INIT) | ||
SET(HAVE_PTHREAD 1) | ||
ENDIF() | ||
|
||
MESSAGE(STATUS "Threads library found: ${Threads_FOUND}") | ||
MESSAGE(STATUS "PThreads compatible: ${CMAKE_USE_PTHREADS_INIT}") | ||
MESSAGE(STATUS "Win32 Threads: ${CMAKE_USE_WIN32_THREADS_INIT}") | ||
|
||
############################################################################### | ||
# Check defines | ||
|
@@ -405,9 +393,9 @@ endif (HAVE_SUBUNIT) | |
|
||
############################################################################### | ||
# Generate "config.h" from "cmake/config.h.in" | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/config.h.in | ||
${CMAKE_CURRENT_BINARY_DIR}/config.h) | ||
# Param @ONLY not used on purpose! | ||
# Param @ONLY not used on purpose! | ||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/config.h.in config.h) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. CMake Variable There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Ah, I completely forgot the library was built as a subproject. Thanks for pointing this out, sorry about that There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Not everybody builds Check as a subproject. Many - if not most - build the Check separately and install it system wide (for all users to access). But CMake allows the inclusion of one project into another. This way of using CMake projects will probably become more popular in the future because it is easier and also more ad hoc and therefore allows for quicker testing. |
||
|
||
include_directories(BEFORE ${CMAKE_CURRENT_BINARY_DIR}) | ||
add_definitions(-DHAVE_CONFIG_H) | ||
set(CONFIG_HEADER ${CMAKE_CURRENT_BINARY_DIR}/config.h) | ||
|
@@ -425,13 +413,16 @@ set(CONFIG_HEADER ${CMAKE_CURRENT_BINARY_DIR}/config.h) | |
# | ||
# When converting to CMake we also want to abandon the m4 macros. | ||
# | ||
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cmake/check_stdint.h.in | ||
${CMAKE_CURRENT_BINARY_DIR}/check_stdint.h @ONLY) | ||
if(NOT THIS_IS_SUBPROJECT) | ||
install( | ||
FILES ${CMAKE_CURRENT_BINARY_DIR}/check_stdint.h | ||
DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}) | ||
endif() | ||
CONFIGURE_FILE(${CMAKE_SOURCE_DIR}/cmake/check_stdint.h.in check_stdint.h @ONLY) | ||
|
||
IF(NOT THIS_IS_SUBPROJECT) | ||
INSTALL( | ||
FILES | ||
check_stdint.h | ||
DESTINATION | ||
${CMAKE_INSTALL_INCLUDEDIR} | ||
) | ||
ENDIF() | ||
|
||
############################################################################### | ||
# Generate "check.pc", the package config (pkgconfig) file for libtool | ||
|
@@ -578,4 +569,3 @@ if(NOT THIS_IS_SUBPROJECT) | |
endif() | ||
|
||
# vim: shiftwidth=2:softtabstop=2:tabstop=2:expandtab:autoindent | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good idea to change the comment row above the code. Comments should precede the code. Otherwise it is misleading.