Skip to content
This repository was archived by the owner on Aug 5, 2022. It is now read-only.

Commit 5437d88

Browse files
committed
Merge pull request #368 from dawagner/cmake-threads
CMake: some modernization
2 parents 2e2c57b + 4e31ead commit 5437d88

File tree

5 files changed

+18
-10
lines changed

5 files changed

+18
-10
lines changed

CMakeLists.txt

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ include(SetVersion.cmake)
5757
# call the wrapper
5858
list(INSERT CMAKE_MODULE_PATH 0 "${CMAKE_CURRENT_LIST_DIR}/cmake")
5959

60+
set(CMAKE_CXX_STANDARD 11)
61+
set(CMAKE_CXX_EXTENSIONS NO)
62+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
63+
6064
if(WIN32)
6165
# By default cmake adds a warning level.
6266
# Nevertheless a different level is wanted for this project.
@@ -76,15 +80,13 @@ if(WIN32)
7680
# and thus are not to be used by the client. A better fix would be to export
7781
# only public methods instead of the whole class, but they are too many to
7882
# do that. A separated plugin interface would fix that.
79-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /FIiso646.h -wd4127 -wd4251")
83+
set_property(DIRECTORY PROPERTY COMPILE_OPTIONS /W4 /FIiso646.h -wd4127 -wd4251)
8084

8185
# FIXME: Once we have removed all warnings on windows, add the /WX flags if
8286
# FATAL_WARNINGS is enabled
8387
else()
84-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -Wextra -Wconversion -Wno-sign-conversion")
85-
if(FATAL_WARNINGS)
86-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror")
87-
endif()
88+
set_property(DIRECTORY PROPERTY COMPILE_OPTIONS -Wall -Wextra -Wconversion -Wno-sign-conversion
89+
$<$<BOOL:FATAL_WARNINGS>:-Werror>)
8890
endif()
8991

9092
# 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)
101103

102104
include(ctest/CMakeLists.txt)
103105

106+
# Since there is no directory-wide property for linker flags, we can't use
107+
# set_property for the link-time coverage flags.
104108
if(COVERAGE)
105109
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fprofile-arcs -ftest-coverage")
106110
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fprofile-arcs -ftest-coverage")

bindings/python/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ set_property(TARGET _PyPfw PROPERTY LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BIN
7676
# generated by swig generates warnings. We don't apply the FATAL_WARNING policy
7777
# here, since we consider this generated code as external.
7878
target_compile_definitions(_PyPfw PRIVATE SWIG_PYTHON_SILENT_MEMLEAK)
79-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wno-error")
79+
target_compile_options(_PyPfw PRIVATE -Wno-error)
8080

8181

8282
# Find the python modules install path.

remote-process/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ if(NETWORKING)
3333
find_package(Threads REQUIRED)
3434

3535
target_link_libraries(remote-process
36-
PRIVATE remote-processor pfw_utility asio ${CMAKE_THREAD_LIBS_INIT})
36+
PRIVATE remote-processor pfw_utility asio Threads::Threads)
3737

3838
install(TARGETS remote-process RUNTIME DESTINATION bin
3939
COMPONENT eng)

remote-processor/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ generate_export_header(remote-processor
4040
set(CMAKE_THREAD_PREFER_PTHREAD 1)
4141
find_package(Threads REQUIRED)
4242

43-
target_link_libraries(remote-processor PRIVATE pfw_utility asio ${CMAKE_THREAD_LIBS_INIT})
43+
target_link_libraries(remote-processor PRIVATE pfw_utility asio Threads::Threads)
4444

4545
install(TARGETS remote-processor EXPORT ParameterTargets
4646
LIBRARY DESTINATION lib COMPONENT runtime

skeleton-subsystem/CMakeLists.txt

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,17 @@ project(parameter-framework-plugins-skeleton)
3333

3434
find_package(ParameterFramework REQUIRED)
3535

36+
set(CMAKE_CXX_STANDARD 11)
37+
set(CMAKE_CXX_EXTENSIONS NO)
38+
set(CMAKE_CXX_STANDARD_REQUIRED YES)
39+
3640
if(WIN32)
3741
# Force include iso646.h to support alternative operator form (and, or, not...)
3842
# Such support is require by the standard and can be enabled with /Za
3943
# but doing so breaks compilation of windows headers...
40-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /FIiso646.h")
44+
set_property(DIRECTORY PROPERTY COMPILE_OPTIONS /W4 /FIiso646.h)
4145
else()
42-
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Werror -Wall -Wextra -Wconversion")
46+
set_property(DIRECTORY PROPERTY COMPILE_OPTIONS -Werror -Wall -Wextra -Wconversion)
4347
endif()
4448

4549
# Hide symbols by default, then exposed symbols are the same in linux and windows

0 commit comments

Comments
 (0)