Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 17 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,23 @@ option(ECAL_INSTALL_SAMPLE_SOURCES "Install the sources of eCAL
option(ECAL_USE_NPCAP "Enable the eCAL Npcap Receiver (i.e. the Win10 performance fix)" OFF)
option(ECAL_USE_CLOCKLOCK_MUTEX "Use native mutex with monotonic clock (requires glibc >= 2.30)" OFF)


# Compiler warnings and additional flag configuration
include(${CMAKE_CURRENT_LIST_DIR}/cmake/helper_functions/ecal_compiler_warnings.cmake)
ecal_get_default_compiler_warnings(ecal_default_warnings)

set(ECAL_COMPILER_WARNINGS "${ecal_default_warnings}" CACHE STRING "List of warning flags for eCAL code")
mark_as_advanced(FORCE ECAL_COMPILER_WARNINGS)

set(ECAL_COMPILER_EXTRA_ARGS "" CACHE STRING "List of additional compiler arguments for eCAL code")
mark_as_advanced(FORCE ECAL_COMPILER_EXTRA_ARGS)

# Internal cache variable combining the warning and extra flags
set(ECAL_COMPILER_ARGS
${ECAL_COMPILER_WARNINGS} ${ECAL_COMPILER_EXTRA_ARGS}
CACHE INTERNAL "Compiler flags used for eCAL code" FORCE
)

# --------------------------------------------------------
# ecal core configuration
# --------------------------------------------------------
Expand Down Expand Up @@ -587,7 +604,6 @@ install(FILES ${eCAL_config} ${eCAL_config_version}

install(FILES
cmake/helper_functions/ecal_add_functions.cmake
cmake/helper_functions/ecal_compiler_warnings.cmake
cmake/helper_functions/ecal_helper_functions.cmake
cmake/helper_functions/ecal_install_functions.cmake
DESTINATION ${${PROJECT_NAME}_install_cmake_dir}/helper_functions
Expand Down
4 changes: 2 additions & 2 deletions app/mon/mon_plugins/monitor_tree_view/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,12 @@ set(source_files

set(CMAKE_AUTOMOC ON)

add_library(${PROJECT_NAME} ${source_files})
ecal_add_library(${PROJECT_NAME} ${source_files})
add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PUBLIC src)

target_link_libraries(${PROJECT_NAME}
target_link_libraries(${PROJECT_NAME} PUBLIC
Qt${QT_VERSION_MAJOR}::Core
Qt${QT_VERSION_MAJOR}::Widgets
CustomQt
Expand Down
2 changes: 1 addition & 1 deletion app/play/play_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ set(source_files
src/measurement_container.h
)

add_library(${PROJECT_NAME} ${source_files})
ecal_add_library(${PROJECT_NAME} ${source_files})
add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PRIVATE src)
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_client_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ if (ECAL_USE_CURL)
)
endif()

add_library (${PROJECT_NAME} ${source_files})
ecal_add_library (${PROJECT_NAME} ${source_files})
add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PRIVATE src)
Expand Down
2 changes: 1 addition & 1 deletion app/rec/rec_server_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ set(source_files
src/recorder/remote_recorder.h
)

add_library (${PROJECT_NAME} ${source_files})
ecal_add_library (${PROJECT_NAME} ${source_files})
add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PRIVATE src)
Expand Down
1 change: 1 addition & 0 deletions app/sys/sys_cli/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ target_link_libraries(${PROJECT_NAME} PRIVATE
protobuf::libprotobuf
CustomTclap
eCAL::core_pb
eCAL::protobuf_core
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)
Expand Down
2 changes: 1 addition & 1 deletion app/sys/sys_client_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ set(source_files
src/task.cpp
)

add_library (${PROJECT_NAME} ${source_files})
ecal_add_library (${PROJECT_NAME} ${source_files})
add_library (eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME} PRIVATE src)
Expand Down
15 changes: 9 additions & 6 deletions app/sys/sys_core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ set(ecalsyscore_src
src/task/task_group.cpp
)

add_library(${PROJECT_NAME} ${ecalsyscore_src})
ecal_add_library(${PROJECT_NAME} ${ecalsyscore_src})
add_library(eCAL::${PROJECT_NAME} ALIAS ${PROJECT_NAME})

target_include_directories(${PROJECT_NAME}
Expand All @@ -87,16 +87,19 @@ target_compile_definitions(${PROJECT_NAME}
create_targets_protobuf()

target_link_libraries(${PROJECT_NAME}
PUBLIC
eCAL::core
spdlog::spdlog
eCAL::sys_client_core
eCAL::core_pb
eCAL::app_pb
eCAL::ecal-utils
PRIVATE
Threads::Threads
tinyxml2::tinyxml2
spdlog::spdlog
protobuf::libprotobuf
eCAL::protobuf_core
eCAL::core_pb
eCAL::app_pb
EcalParser
eCAL::sys_client_core
eCAL::ecal-utils
)

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)
Expand Down
1 change: 1 addition & 0 deletions app/sys/sys_gui/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,7 @@ target_link_libraries (${PROJECT_NAME} PRIVATE
CustomTclap
tclap::tclap
eCAL::core
eCAL::protobuf_core
eCAL::sys_core
protobuf::libprotobuf
EcalParser
Expand Down
32 changes: 21 additions & 11 deletions cmake/helper_functions/ecal_add_functions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,17 @@

include_guard(GLOBAL)

include("${CMAKE_CURRENT_LIST_DIR}/ecal_compiler_warnings.cmake")
# ECAL_COMPILER_WARNINGS is set by the root CMakeLists and may be user customized
add_library(_ecal_compiler_args INTERFACE)
target_compile_options(_ecal_compiler_args INTERFACE
"$<$<COMPILE_LANGUAGE:C,CXX>:${ECAL_COMPILER_ARGS}>"
)

function(ecal_add_compiler_flags TARGET_NAME)
target_link_libraries("${TARGET_NAME}" PRIVATE
"$<BUILD_INTERFACE:_ecal_compiler_args>"
)
endfunction()

# This function will set the output names of the target according to eCAL conventions.
function(ecal_add_app_console TARGET_NAME)
Expand All @@ -28,7 +38,7 @@ function(ecal_add_app_console TARGET_NAME)
VERSION ${eCAL_VERSION_STRING}
SOVERSION ${eCAL_VERSION_MAJOR}
OUTPUT_NAME ecal_${TARGET_NAME})
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

# This helper function automatically adds a gtest to ecal.
Expand All @@ -55,7 +65,7 @@ function(ecal_add_gtest TARGET_NAME)
VERSION ${eCAL_VERSION_STRING}
SOVERSION ${eCAL_VERSION_MAJOR}
OUTPUT_NAME ecal_${TARGET_NAME})
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_app_gui TARGET_NAME)
Expand All @@ -65,7 +75,7 @@ function(ecal_add_app_gui TARGET_NAME)
VERSION ${eCAL_VERSION_STRING}
SOVERSION ${eCAL_VERSION_MAJOR}
OUTPUT_NAME ecal_${TARGET_NAME})
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_app_qt TARGET_NAME)
Expand All @@ -77,7 +87,7 @@ function(ecal_add_app_qt TARGET_NAME)
if(WIN32)
set_target_properties(${PROJECT_NAME} PROPERTIES LINK_FLAGS "/SUBSYSTEM:WINDOWS /ENTRY:mainCRTStartup")
endif()
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_mon_plugin TARGET_NAME)
Expand All @@ -102,7 +112,7 @@ function(ecal_add_mon_plugin TARGET_NAME)
$<$<CONFIG:RelWithDebInfo>:QT_NO_DEBUG>
$<$<CONFIG:MinSizeRel>:QT_NO_DEBUG>
)
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_rec_addon TARGET_NAME)
Expand All @@ -113,7 +123,7 @@ function(ecal_add_rec_addon TARGET_NAME)
OUTPUT_NAME ecal_${TARGET_NAME}
RUNTIME_OUTPUT_DIRECTORY $<IF:$<BOOL:${WIN32}>,${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/$<CONFIG>/ecalrec_addons,${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ecal/addons/rec>
)
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_time_plugin TARGET_NAME)
Expand All @@ -122,7 +132,7 @@ function(ecal_add_time_plugin TARGET_NAME)
VERSION ${eCAL_VERSION_STRING}
SOVERSION ${eCAL_VERSION_MAJOR}
)
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_shared_library TARGET_NAME)
Expand All @@ -131,7 +141,7 @@ function(ecal_add_shared_library TARGET_NAME)
VERSION ${eCAL_VERSION_STRING}
SOVERSION ${eCAL_VERSION_MAJOR}
OUTPUT_NAME ecal_${TARGET_NAME})
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_static_library TARGET_NAME)
Expand All @@ -142,7 +152,7 @@ function(ecal_add_static_library TARGET_NAME)
OUTPUT_NAME ecal_${TARGET_NAME}
POSITION_INDEPENDENT_CODE ON
)
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

function(ecal_add_interface_library TARGET_NAME)
Expand All @@ -163,6 +173,6 @@ function(ecal_add_sample TARGET_NAME)
VERSION ${eCAL_VERSION_STRING}
SOVERSION ${eCAL_VERSION_MAJOR}
OUTPUT_NAME ecal_sample_${TARGET_NAME})
ecal_add_compiler_warnings(${TARGET_NAME})
ecal_add_compiler_flags(${TARGET_NAME})
endfunction()

34 changes: 12 additions & 22 deletions cmake/helper_functions/ecal_compiler_warnings.cmake
Original file line number Diff line number Diff line change
@@ -1,27 +1,17 @@
include_guard(GLOBAL)

add_library(_ecal_warnings INTERFACE)
function(ecal_get_default_compiler_warnings cxx_out_var)
set(cxx_compiler_flags "")

set(cxx_compiler_flags "")
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
message(STATUS "MSVC detected - Adding flags")
set(cxx_compiler_flags "/MP" "/W4")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang")
message(STATUS "Setting GNU/Clang flags")
set(cxx_compiler_flags "-Wall" "-Wextra")
else()
message(WARNING "Unknown compiler, will not set warning flags")
endif()

if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
message(STATUS "MSVC detected - Adding flags")
set(cxx_compiler_flags "/MP" "/W4")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang")
message(STATUS "Setting GNU/Clang flags")
set(cxx_compiler_flags "-Wall" "-Wextra")
else()
message(WARNING "Unknown compiler, will not set warning flags")
endif()

target_compile_options(_ecal_warnings INTERFACE
"$<$<COMPILE_LANGUAGE:C,CXX>:${cxx_compiler_flags}>"
)

unset(cxx_compiler_flags)

function(ecal_add_compiler_warnings TARGET_NAME)
target_link_libraries("${TARGET_NAME}" PRIVATE
"$<BUILD_INTERFACE:_ecal_warnings>"
)
set("${cxx_out_var}" "${cxx_compiler_flags}" PARENT_SCOPE)
endfunction()
4 changes: 2 additions & 2 deletions contrib/measurement/base/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ project(measurement)
###################################
# Base Measurement common headers #
###################################
add_library(measurement_base INTERFACE)
ecal_add_interface_library(measurement_base)
add_library(eCAL::measurement_base ALIAS measurement_base)

target_sources(measurement_base
Expand Down Expand Up @@ -49,7 +49,7 @@ install(
###################################
# Measurement library #
###################################
add_library(measurement INTERFACE)
ecal_add_interface_library(measurement)
add_library(eCAL::measurement ALIAS measurement)

target_sources(measurement
Expand Down
2 changes: 1 addition & 1 deletion contrib/measurement/hdf5/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@

project(measurement_hdf5)

add_library(${PROJECT_NAME}
ecal_add_library(${PROJECT_NAME}
include/ecal/measurement/hdf5/reader.h
include/ecal/measurement/hdf5/writer.h
src/reader.cpp
Expand Down
19 changes: 19 additions & 0 deletions ecal/service/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,25 @@
cmake_minimum_required(VERSION 3.16)
project(ecal_service)

if(TARGET _ecal_compiler_args)
# _ecal_compiler_args is the internal eCAL target containing the warning flags
# and will be absent if this is being built standalone
add_library(_ecal_service_warnings ALIAS _ecal_compiler_args)
else()
# Otherwise, use a fallback implementation
if("${CMAKE_CXX_COMPILER_ID}" MATCHES "MSVC")
set(cxx_compiler_flags "/MP" "/W4")
elseif("${CMAKE_CXX_COMPILER_ID}" MATCHES "GNU|Clang")
set(cxx_compiler_flags "-Wall" "-Wextra")
else()
message(WARNING "Unknown compiler, will not set warning flags")
endif()

set(ECAL_SERVICE_COMPILER_WARNINGS "${cxx_compiler_flags}" CACHE STRING "Warning flags used for eCAL service code")
add_library(_ecal_service_warnings INTERFACE)
target_compile_options(_ecal_service_warnings INTERFACE "${ECAL_SERVICE_COMPILER_WARNINGS}")
endif()

# Main library
add_subdirectory(ecal_service)

Expand Down
9 changes: 2 additions & 7 deletions ecal/service/ecal_service/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
cmake_minimum_required(VERSION 3.5.1)
cmake_minimum_required(VERSION 3.16)

project(ecal_service)

Expand Down Expand Up @@ -61,6 +61,7 @@ target_link_libraries(${PROJECT_NAME}
Threads::Threads
$<$<BOOL:${WIN32}>:ws2_32>
$<$<BOOL:${WIN32}>:wsock32>
_ecal_service_warnings

)

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

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_14)

target_compile_options(${PROJECT_NAME} PRIVATE
$<$<OR:$<CXX_COMPILER_ID:Clang>,$<CXX_COMPILER_ID:AppleClang>,$<CXX_COMPILER_ID:GNU>>:
-Wall -Wextra>
$<$<CXX_COMPILER_ID:MSVC>:
/W4>)

# Add own public include directory
target_include_directories(${PROJECT_NAME}
PUBLIC
Expand Down
4 changes: 3 additions & 1 deletion ecal/service/samples/sample_client/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ add_executable(${PROJECT_NAME} ${sources})

target_link_libraries(${PROJECT_NAME}
PRIVATE
ecal_service)
ecal_service
_ecal_service_warnings
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)

Expand Down
4 changes: 3 additions & 1 deletion ecal/service/samples/sample_server/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ add_executable(${PROJECT_NAME} ${sources})

target_link_libraries(${PROJECT_NAME}
PRIVATE
ecal_service)
ecal_service
_ecal_service_warnings
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)

Expand Down
4 changes: 3 additions & 1 deletion ecal/service/samples/sample_standalone/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ add_executable(${PROJECT_NAME} ${sources})

target_link_libraries(${PROJECT_NAME}
PRIVATE
ecal_service)
ecal_service
_ecal_service_warnings
)

target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_14)

Expand Down
Loading
Loading