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

Commit 4e31ead

Browse files
committed
CMake: use the COMPILE_OPTIONS property instead of CMAKE_CXX_FLAGS
Signed-off-by: David Wagner <[email protected]>
1 parent e8bda4a commit 4e31ead

File tree

3 files changed

+16
-8
lines changed

3 files changed

+16
-8
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.

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)