From 76fcc3b460d489cf8a1aad4be06b49d19bb138df Mon Sep 17 00:00:00 2001 From: Nathanael Sensfelder Date: Fri, 6 May 2016 10:14:47 +0200 Subject: Makes the main CMakeLists.txt more portable. The POSIX version was previously only set in files. Having it set at the root level makes more sense, especially considering that the previous method could make successful compilation of the project dependent on the order in which files are compiled. Which obviously not acceptable. Flags were also set in a way that made them potentially only compatible with GNUCC. This is now fixed (the optimization flag remains GNUCC only, but a check for which compiler is used precedes it). --- CMakeLists.txt | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ba70690..2df7e18 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,7 +5,18 @@ project("Zero of One") include(FindPkgConfig) add_subdirectory(src) -set(CMAKE_C_FLAGS "-D_POSIX_SOURCE -std=c99 -O2") +add_definitions(-D_POSIX_SOURCE) +add_definitions(-D_POSIX_C_SOURCE=200809L) + +if(CMAKE_COMPILER_IS_GNUCC) + message(STATUS "GNUCC detected. Adding '-02' parameter.") + set(CMAKE_C_FLAGS "-O2") +endif() + # ${SRC_FILES} is recursively defined in the subdirectories. # Each subdirectory only adds the source files that are present at its level. add_executable(zero_of_one ${SRC_FILES}) +set_property(TARGET zero_of_one PROPERTY C_STANDARD 99) +set_property(TARGET zero_of_one PROPERTY C_STANDARD_REQUIRED ON) +#find_package(Threads) +#target_link_libraries(cborg ${CMAKE_THREAD_LIBS_INIT}) -- cgit v1.2.3-70-g09d2