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

Commit

Permalink
Merge pull request #368 from dawagner/cmake-threads
Browse files Browse the repository at this point in the history
CMake: some modernization
  • Loading branch information
dawagner committed May 17, 2016
2 parents 2e2c57b + 4e31ead commit 5437d88
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 10 deletions.
14 changes: 9 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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
$<$<BOOL:FATAL_WARNINGS>:-Werror>)
endif()

# Hide symbols by default, then exposed symbols are the same in linux and windows
Expand All @@ -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")
Expand Down
2 changes: 1 addition & 1 deletion bindings/python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion remote-process/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion remote-processor/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 6 additions & 2 deletions skeleton-subsystem/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5437d88

Please sign in to comment.