From e8bda4aca94f00b7a9ea15dc59a08f7524fcbcb4 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Fri, 13 May 2016 11:10:19 +0200 Subject: [PATCH 1/2] CMake: FindThreads now defines a Threads::Threads imported library It looks nicer linking to that imported library than to ${CMAKE_THREAD_LIBS_INIT}. Signed-off-by: David Wagner --- remote-process/CMakeLists.txt | 2 +- remote-processor/CMakeLists.txt | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/remote-process/CMakeLists.txt b/remote-process/CMakeLists.txt index a7fc63b79..f9c9bc317 100644 --- a/remote-process/CMakeLists.txt +++ b/remote-process/CMakeLists.txt @@ -33,7 +33,7 @@ if(NETWORKING) find_package(Threads REQUIRED) target_link_libraries(remote-process - PRIVATE remote-processor pfw_utility asio ${CMAKE_THREAD_LIBS_INIT}) + PRIVATE remote-processor pfw_utility asio Threads::Threads) install(TARGETS remote-process RUNTIME DESTINATION bin COMPONENT eng) diff --git a/remote-processor/CMakeLists.txt b/remote-processor/CMakeLists.txt index d1d0d3257..80f272ac8 100644 --- a/remote-processor/CMakeLists.txt +++ b/remote-processor/CMakeLists.txt @@ -40,7 +40,7 @@ generate_export_header(remote-processor set(CMAKE_THREAD_PREFER_PTHREAD 1) find_package(Threads REQUIRED) -target_link_libraries(remote-processor PRIVATE pfw_utility asio ${CMAKE_THREAD_LIBS_INIT}) +target_link_libraries(remote-processor PRIVATE pfw_utility asio Threads::Threads) install(TARGETS remote-processor EXPORT ParameterTargets LIBRARY DESTINATION lib COMPONENT runtime From 4e31ead93009a5ed5b1c5e87d2edfc3e4908c084 Mon Sep 17 00:00:00 2001 From: David Wagner Date: Fri, 13 May 2016 13:57:05 +0200 Subject: [PATCH 2/2] CMake: use the COMPILE_OPTIONS property instead of CMAKE_CXX_FLAGS Signed-off-by: David Wagner --- CMakeLists.txt | 14 +++++++++----- bindings/python/CMakeLists.txt | 2 +- skeleton-subsystem/CMakeLists.txt | 8 ++++++-- 3 files changed, 16 insertions(+), 8 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 817421865..0323247c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,6 +57,10 @@ include(SetVersion.cmake) # call the wrapper list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake") +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_EXTENSIONS NO) +set(CMAKE_CXX_STANDARD_REQUIRED YES) + if(WIN32) # By default cmake adds a warning level. # Nevertheless a different level is wanted for this project. @@ -76,15 +80,13 @@ if(WIN32) # and thus are not to be used by the client. A better fix would be to export # only public methods instead of the whole class, but they are too many to # do that. A separated plugin interface would fix that. - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /FIiso646.h -wd4127 -wd4251") + set_property(DIRECTORY PROPERTY COMPILE_OPTIONS /W4 /FIiso646.h -wd4127 -wd4251) # FIXME: Once we have removed all warnings on windows, add the /WX flags if # FATAL_WARNINGS is enabled else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wconversion -Wno-sign-conversion") - if(FATAL_WARNINGS) - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror") - endif() + set_property(DIRECTORY PROPERTY COMPILE_OPTIONS -Wall -Wextra -Wconversion -Wno-sign-conversion + $<$:-Werror>) endif() # Hide symbols by default, then exposed symbols are the same in linux and windows @@ -101,6 +103,8 @@ set(CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) include(ctest/CMakeLists.txt) +# Since there is no directory-wide property for linker flags, we can't use +# set_property for the link-time coverage flags. if(COVERAGE) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage") set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage") diff --git a/bindings/python/CMakeLists.txt b/bindings/python/CMakeLists.txt index bdb6513e0..23e08c1f9 100644 --- a/bindings/python/CMakeLists.txt +++ b/bindings/python/CMakeLists.txt @@ -76,7 +76,7 @@ set_property(TARGET _PyPfw PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BIN # generated by swig generates warnings. We don't apply the FATAL_WARNING policy # here, since we consider this generated code as external. target_compile_definitions(_PyPfw PRIVATE SWIG_PYTHON_SILENT_MEMLEAK) -set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error") +target_compile_options(_PyPfw PRIVATE -Wno-error) # Find the python modules install path. diff --git a/skeleton-subsystem/CMakeLists.txt b/skeleton-subsystem/CMakeLists.txt index 1bc1d874c..4016a415f 100644 --- a/skeleton-subsystem/CMakeLists.txt +++ b/skeleton-subsystem/CMakeLists.txt @@ -33,13 +33,17 @@ project(parameter-framework-plugins-skeleton) find_package(ParameterFramework REQUIRED) +set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_EXTENSIONS NO) +set(CMAKE_CXX_STANDARD_REQUIRED YES) + if(WIN32) # Force include iso646.h to support alternative operator form (and, or, not...) # Such support is require by the standard and can be enabled with /Za # but doing so breaks compilation of windows headers... - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /FIiso646.h") + set_property(DIRECTORY PROPERTY COMPILE_OPTIONS /W4 /FIiso646.h) else() - set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -Wconversion") + set_property(DIRECTORY PROPERTY COMPILE_OPTIONS -Werror -Wall -Wextra -Wconversion) endif() # Hide symbols by default, then exposed symbols are the same in linux and windows