Skip to content

Commit 1a0d8d4

Browse files
committed
Apply warnings target to remaining libraries
1 parent 8fcd873 commit 1a0d8d4

File tree

3 files changed

+24
-10
lines changed

3 files changed

+24
-10
lines changed

ecal/service/CMakeLists.txt

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,28 @@
1919
cmake_minimum_required(VERSION 3.16)
2020
project(ecal_service)
2121

22+
# Root CMakeLists sets CMAKE_MODULE_PATH to include the correct path
23+
# If the module cannot be found warnings basic warnings will be applied instead
24+
include(helper_functions/ecal_compiler_warnings OPTIONAL RESULT_VARIABLE _ecal_warnings_found)
25+
if("${_ecal_warnings_found}" STREQUAL "NOTFOUND")
26+
message(AUTHOR_WARNING
27+
" helper_functions/ecal_compiler_warnings.cmake not found.\n"
28+
" Add the path to CMAKE_MODULE_PATH to use warnings specified by the main eCAL repo."
29+
)
30+
add_library(_ecal_service_warnings INTERFACE)
31+
set(cxx_compiler_flags "")
32+
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
33+
set(cxx_compiler_flags "/MP" "/W4")
34+
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang")
35+
set(cxx_compiler_flags "-Wall" "-Wextra")
36+
else()
37+
message(WARNING "Unknown compiler, will not set warning flags")
38+
endif()
39+
target_compile_options(_ecal_service_warnings INTERFACE "${cxx_compiler_flags}")
40+
else()
41+
add_library(_ecal_service_warnings ALIAS _ecal_warnings)
42+
endif()
43+
2244
# Main library
2345
add_subdirectory(ecal_service)
2446

ecal/service/ecal_service/CMakeLists.txt

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
cmake_minimum_required(VERSION 3.5.1)
1+
cmake_minimum_required(VERSION 3.16)
22

33
project(ecal_service)
44

@@ -61,6 +61,7 @@ target_link_libraries(${PROJECT_NAME}
6161
Threads::Threads
6262
$<$<BOOL:${WIN32}>:ws2_32>
6363
$<$<BOOL:${WIN32}>:wsock32>
64+
_ecal_service_warnings
6465

6566
)
6667

@@ -72,12 +73,6 @@ target_compile_definitions(${PROJECT_NAME}
7273

7374
target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)
7475

75-
target_compile_options(${PROJECT_NAME} PRIVATE
76-
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
77-
-Wall -Wextra>
78-
$<$<CXX_COMPILER_ID:MSVC>:
79-
/W4>)
80-
8176
# Add own public include directory
8277
target_include_directories(${PROJECT_NAME}
8378
PUBLIC

lib/EcalParser/CMakeLists.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ set(sources
4545
# QEcalParser is an internal implementation detail for applications so it can
4646
# always be static and not installed/exported
4747
ecal_add_static_library(${PROJECT_NAME}
48-
${includes}
49-
${sources}
50-
)
5148

5249
target_include_directories(${PROJECT_NAME} PUBLIC include/)
5350
target_include_directories(${PROJECT_NAME} PRIVATE src/)

0 commit comments

Comments
 (0)