From: Marcus Fritzsch Date: Mon, 26 Jun 2017 10:15:27 +0000 (+0200) Subject: cmake: modernized to the best of my knowledge X-Git-Tag: 4.99.1~316 X-Git-Url: https://gerrit.automotivelinux.org/gerrit/gitweb?a=commitdiff_plain;h=59e0e42d7f612f4e9f526a0632a86dc0300ad76f;p=staging%2Fwindowmanager.git cmake: modernized to the best of my knowledge Signed-off-by: Marcus Fritzsch --- diff --git a/CMakeLists.txt b/CMakeLists.txt index 1654333..5d38309 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -11,9 +11,11 @@ find_package(PkgConfig REQUIRED) pkg_check_modules(WLC wayland-client>=1.11.0 REQUIRED) -find_program(WLSCAN NAMES wayland-scanner) - macro(wlproto var_basename proto_xml_basename) + if("${WLSCAN}" STREQUAL "") + find_program(WLSCAN NAMES wayland-scanner) + endif() + if(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/protocol) set(proto_dir "${CMAKE_CURRENT_SOURCE_DIR}/protocol") elseif(EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/../protocol) @@ -40,6 +42,7 @@ macro(wlproto var_basename proto_xml_basename) include_directories(${CMAKE_CURRENT_BINARY_DIR}) endmacro() +# Should modernize the following somehow... set(ENABLE_DEBUG_OUTPUT OFF CACHE BOOL "Enable debug logging") if(ENABLE_DEBUG_OUTPUT) add_definitions(-DDEBUG_OUTPUT) @@ -47,16 +50,6 @@ else() remove_definitions(-DDEBUG_OUTPUT) endif() -add_definitions(-D_GNU_SOURCE) - -set(CMAKE_C_FLAGS "-Wall -Wextra -Wno-comment -Wno-unused-parameter -fvisibility=hidden -std=c99 ${CMAKE_C_FLAGS}") -set(CMAKE_CXX_FLAGS "-Wall -Wextra -Wno-comment -Wno-unused-parameter -fvisibility=hidden -std=c++14 ${CMAKE_CXX_FLAGS}") - set(SANITIZER_MODE "none" CACHE STRING "Build using a specific sanitizer (e.g. 'address', 'thread', 'leak', 'undefined'), depends on compiler; default none") -if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "") - set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer") - set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=${SANITIZER_MODE} -g") - set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -fsanitize=${SANITIZER_MODE} -g") -endif() add_subdirectory(src) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index b11d397..aa1c2a0 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -10,7 +10,35 @@ add_executable(winman ${IVI_APP_PROTO} ${IVI_CON_PROTO}) -add_definitions(-DWINMAN_VERSION_STRING="${PACKAGE_VERSION}") +target_compile_definitions(winman + PRIVATE + WINMAN_VERSION_STRING="${PACKAGE_VERSION}" + _GNU_SOURCE) # XXX should I define this here?! + +target_compile_options(winman + PRIVATE + -Wall -Wextra -Wno-unused-parameter -Wno-comment) + +set_target_properties(winman + PROPERTIES + CXX_EXTENSIONS OFF + CXX_STANDARD 14 + CXX_STANDARD_REQUIRED ON) + +set_target_properties(winman + PROPERTIES + C_EXTENSIONS OFF + C_STANDARD 99 + C_STANDARD_REQUIRED ON) + +if (NOT ${SANITIZER_MODE} STREQUAL "none" AND NOT ${SANITIZER_MODE} STREQUAL "") + target_compile_options(winman + PRIVATE + -fsanitize=${SANITIZER_MODE} -g -fno-omit-frame-pointer) + set_target_properties(winman + PROPERTIES + LINK_FLAGS "-fsanitize=${SANITIZER_MODE} -g") +endif() target_link_libraries(winman ${WLC_LIBRARIES})