cleaned up setting of compiler options and a few more things in CMake (#2599)

* cleaned up compiler options related code in CMake

* moved cmake_minimum_required() and raised to latest 2.8.x version

* use proper compiler version check / print compiler version

* fixed linking of sanitized builds

* added proper version checks to newer Clang warnings and enabled them / moved tinyxml_objs flags to proper compiler

* disabled -Wdeprecated-declarations for Clang

* compileroptions.cmake: removed unnecessary check for clang++ existence - CMAKE_CXX_COMPILER_ID is determined by CMake

* printInfo.cmake: removed unnecessary message for ANALYZE_ADDRESS - LSAN is part of ASAN and enabled by default

* cleaned up if() comparisons in CMake

* added/adjusted TODOs
This commit is contained in:
Oliver Stöneberg 2020-04-22 11:04:19 +02:00 committed by GitHub
parent 387f0a268b
commit 1388e9385b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
13 changed files with 106 additions and 165 deletions

View File

@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 2.8.12)
project(Cppcheck)
cmake_minimum_required(VERSION 2.8.11)
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)

View File

@ -1,5 +1,5 @@
if (UNIX)
if (${CMAKE_BUILD_TYPE} STREQUAL "Debug")
if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-D_GLIBCXX_DEBUG)
endif()
if (HAVE_RULES)

View File

@ -1,108 +1,64 @@
set(EXTRA_C_FLAGS "")
set(EXTRA_C_FLAGS_RELEASE "-DNDEBUG")
set(EXTRA_C_FLAGS_DEBUG "-DDEBUG")
if (USE_CLANG)
set (CMAKE_C_COMPILER_ID "Clang")
set (CMAKE_CXX_COMPILER_ID "Clang")
set (CMAKE_C_COMPILER "/usr/bin/clang")
set (CMAKE_CXX_COMPILER "/usr/bin/clang++")
set (CMAKE_C_FLAGS "-std=c99")
set (CMAKE_C_FLAGS_DEBUG "-g")
set (CMAKE_C_FLAGS_RELEASE "-O2")
set (CMAKE_CXX_FLAGS "-pedantic -Wall -Wextra")
set (CMAKE_CXX_FLAGS_DEBUG "-g")
set (CMAKE_CXX_FLAGS_RELEASE "-O2")
if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-DDEBUG)
elseif(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
add_definitions(-DNDEBUG)
endif()
if (USE_ANALYZE)
set (CMAKE_C_COMPILER_ID "ccc-analyzer")
set (CMAKE_CXX_COMPILER_ID "c++-analyzer")
set (CMAKE_C_COMPILER "/usr/share/clang/scan-build/ccc-analyzer")
set (CMAKE_CXX_COMPILER "/usr/share/clang/scan-build/c++-analyzer")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU" OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (CMAKE_BUILD_TYPE MATCHES "Debug")
add_definitions(-g -O0)
elseif(CMAKE_BUILD_TYPE MATCHES "Release" OR CMAKE_BUILD_TYPE MATCHES "RelWithDebInfo")
add_definitions(-O2)
endif()
set (CMAKE_C_FLAGS "-Wall -std=c99")
set (CMAKE_C_FLAGS_DEBUG "-g")
set (CMAKE_C_FLAGS_RELEASE "-O2")
set (CMAKE_CXX_FLAGS "-pedantic -Wall -Wextra")
set (CMAKE_CXX_FLAGS_DEBUG "-g")
set (CMAKE_CXX_FLAGS_RELEASE "-O2")
if (WARNINGS_ARE_ERRORS)
add_compile_options(-Werror)
endif()
endif()
set(CMAKE_CXX_FLAGS_ASAN "-g -fsanitize=address,undefined -fno-sanitize-recover=all"
CACHE STRING "Compiler flags in asan build"
FORCE)
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU")
execute_process(COMMAND ${CMAKE_CXX_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (NOT (GCC_VERSION VERSION_GREATER 4.6 OR GCC_VERSION VERSION_EQUAL 4.6))
message(FATAL_ERROR "${PROJECT_NAME} c++11 support requires g++ 4.6 or greater, but it is ${GCC_VERSION}")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 4.6)
message(FATAL_ERROR "${PROJECT_NAME} c++11 support requires g++ 4.6 or greater, but it is ${CMAKE_CXX_COMPILER_VERSION}")
endif ()
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wcast-qual") # Cast for removing type qualifiers
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-deprecated-declarations")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wfloat-equal") # Floating values used in equality comparisons
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wmissing-declarations") # If a global function is defined without a previous declaration
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wmissing-format-attribute") #
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-long-long")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Woverloaded-virtual") # when a function declaration hides virtual functions from a base class
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wpacked") #
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wredundant-decls") # if anything is declared more than once in the same scope
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wundef")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-shadow") # whenever a local variable or type declaration shadows another one
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-missing-field-initializers")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-missing-braces")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-sign-compare")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-multichar")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
add_compile_options(-Wcast-qual) # Cast for removing type qualifiers
add_compile_options(-Wno-deprecated-declarations)
add_compile_options(-Wfloat-equal) # Floating values used in equality comparisons
add_compile_options(-Wmissing-declarations) # If a global function is defined without a previous declaration
add_compile_options(-Wmissing-format-attribute) #
add_compile_options(-Wno-long-long)
add_compile_options(-Woverloaded-virtual) # when a function declaration hides virtual functions from a base class
add_compile_options(-Wpacked) #
add_compile_options(-Wredundant-decls) # if anything is declared more than once in the same scope
add_compile_options(-Wundef)
add_compile_options(-Wno-shadow) # whenever a local variable or type declaration shadows another one
add_compile_options(-Wno-missing-field-initializers)
add_compile_options(-Wno-missing-braces)
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-multichar)
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(NOT EXISTS ${CMAKE_CXX_COMPILER})
MESSAGE( FATAL_ERROR "Clang++ not found. " )
add_compile_options(-Wno-deprecated-declarations)
add_compile_options(-Wno-four-char-constants)
add_compile_options(-Wno-missing-braces)
add_compile_options(-Wno-missing-field-initializers)
add_compile_options(-Wno-multichar)
add_compile_options(-Wno-sign-compare)
add_compile_options(-Wno-unused-function)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
add_compile_options(-Wextra-semi-stmt)
endif()
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-four-char-constants")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-missing-braces")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-missing-field-initializers")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-multichar")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-sign-compare")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wno-unused-function")
# TODO: enable this warning - was added in Clang 8
#set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wextra-semi-stmt")
if(ENABLE_COVERAGE OR ENABLE_COVERAGE_XML)
MESSAGE(FATAL_ERROR "Not use clang for generate code coverage. Use gcc. ")
message(FATAL_ERROR "Not use clang for generate code coverage. Use gcc.")
endif()
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "c++-analyzer")
if(NOT EXISTS ${CMAKE_CXX_COMPILER})
MESSAGE( FATAL_ERROR "c++-analyzer not found. " )
endif()
if(ENABLE_COVERAGE)
MESSAGE(FATAL_ERROR "Not use c++-analyzer for generate code coverage. Use gcc. ")
endif()
endif()
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang" OR
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "c++-analyzer" )
# TODO: check if this can be enabled again - also done in Makefile
if (CMAKE_SYSTEM_NAME MATCHES "Linux" AND
CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if(WARNINGS_ARE_ERRORS)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Werror")
endif()
set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG} -O0")
endif()
if ("${CMAKE_SYSTEM_NAME}" STREQUAL "Linux" AND
"${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -U_GLIBCXX_DEBUG")
add_compile_options(-U_GLIBCXX_DEBUG)
endif()
if (MSVC)
@ -110,22 +66,8 @@ if (MSVC)
endif()
if (CYGWIN)
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -Wl,--stack,8388608")
# TODO: this is a linker flag - not a compiler flag
add_compile_options(-Wl,--stack,8388608)
endif()
include(cmake/dynamic_analyzer_options.cmake REQUIRED)
# Add user supplied extra options (optimization, etc...)
# ==========================================================
set(EXTRA_C_FLAGS "${EXTRA_C_FLAGS}" CACHE INTERNAL "Extra compiler options")
set(EXTRA_C_FLAGS_RELEASE "${EXTRA_C_FLAGS_RELEASE}" CACHE INTERNAL "Extra compiler options for Release build")
set(EXTRA_C_FLAGS_DEBUG "${EXTRA_C_FLAGS_DEBUG}" CACHE INTERNAL "Extra compiler options for Debug build")
#combine all "extra" options
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} ${EXTRA_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} ${EXTRA_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${EXTRA_C_FLAGS}")
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} ${EXTRA_C_FLAGS_RELEASE}")
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} ${EXTRA_C_FLAGS_DEBUG}")
include(cmake/dynamic_analyzer_options.cmake)

View File

@ -1,8 +1,8 @@
macro(use_cxx11)
if (CMAKE_VERSION VERSION_LESS "3.1")
if (CMAKE_CXX_COMPILER_ID STREQUAL "GNU")
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
elseif ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
elseif (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
set (CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif ()
else ()

View File

@ -1,31 +1,31 @@
IF (USE_CLANG)
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fdiagnostics-show-category=name")
ENDIF()
IF(ANALYZE_MEMORY)
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fsanitize=memory")
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fsanitize-memory-track-origins=2")
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fno-omit-frame-pointer")
if(ANALYZE_MEMORY)
add_compile_options(-fsanitize=memory)
add_compile_options(-fsanitize-memory-track-origins=2)
add_compile_options(-fno-omit-frame-pointer)
# NOTE: tail call elimination -fno-optimize-sibling-calls
ELSEIF(ANALYZE_ADDRESS)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=memory")
elseif(ANALYZE_ADDRESS)
add_compile_options(-fsanitize=address)
add_compile_options(-fno-omit-frame-pointer)
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fsanitize=address")
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fno-omit-frame-pointer")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=address")
elseif(ANALYZE_THREAD)
add_compile_options(-fsanitize=thread)
ELSEIF(ANALYZE_THREAD)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=thread")
endif()
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fsanitize=thread")
if(ANALYZE_UNDEFINED)
add_compile_options(-fsanitize=undefined-trap)
add_compile_options(-fsanitize-undefined-trap-on-error)
add_compile_options(-fno-sanitize-recover)
ENDIF()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=undefined")
endif()
IF(ANALYZE_UNDEFINED)
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fsanitize=undefined-trap")
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fsanitize-undefined-trap-on-error")
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fno-sanitize-recover")
ENDIF()
if(ANALYZE_DATAFLOW)
add_compile_options(-fsanitize=dataflow)
IF(ANALYZE_DATAFLOW)
SET(EXTRA_C_FLAGS "${EXTRA_C_FLAGS} -fsanitize=dataflow")
ENDIF()
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -fsanitize=dataflow")
endif()

View File

@ -16,7 +16,7 @@ endif()
set(CMAKE_INCLUDE_CURRENT_DIR ON)
set(CMAKE_AUTOMOC OFF)
if (NOT ${USE_MATCHCOMPILER_OPT} STREQUAL "Off")
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
find_package(PythonInterp)
if (NOT ${PYTHONINTERP_FOUND})
message(WARNING "No python interpreter found. Therefore, the match compiler is switched off.")

View File

@ -13,8 +13,6 @@ endif()
# ----------------------------------------------------------------------------
# PROJECT CONFIGURATION
# ----------------------------------------------------------------------------
option(USE_CLANG "Use Clang compiler" OFF)
option(USE_ANALYZE "Use Clang compiler with analyze mode" OFF)
option(ANALYZE_MEMORY "Clang dynamic analyzer: detector of uninitialized reads." OFF)
option(ANALYZE_ADDRESS "Clang dynamic analyzer: fast memory error detector. " OFF)
option(ANALYZE_THREAD "Clang dynamic analyzer: tool that detects data races. " OFF)
@ -24,8 +22,8 @@ option(WARNINGS_ARE_ERRORS "Treat warnings as errors"
set(USE_MATCHCOMPILER "Auto" CACHE STRING "Usage of match compiler")
set_property(CACHE USE_MATCHCOMPILER PROPERTY STRINGS Auto Off On Verify)
if (USE_MATCHCOMPILER STREQUAL "Auto")
if (NOT CMAKE_BUILD_TYPE STREQUAL "Debug")
if (USE_MATCHCOMPILER MATCHES "Auto")
if (NOT CMAKE_BUILD_TYPE MATCHES "Debug")
set(USE_MATCHCOMPILER_OPT "On")
else()
set(USE_MATCHCOMPILER_OPT "Off")

View File

@ -2,6 +2,7 @@ message( STATUS "------------------ General configuration for ${PROJECT_NAME} ${
message( STATUS )
message( STATUS "CMake Generator = ${CMAKE_GENERATOR}")
message( STATUS "Compiler = ${CMAKE_CXX_COMPILER_ID}")
message( STATUS "Compiler Version = ${CMAKE_CXX_COMPILER_VERSION}")
message( STATUS "Build type = ${CMAKE_BUILD_TYPE}")
message( STATUS "CMAKE_INSTALL_PREFIX = ${CMAKE_INSTALL_PREFIX}" )
message( STATUS "C++ flags (General) = ${CMAKE_CXX_FLAGS}")
@ -13,8 +14,6 @@ foreach( d ${DirDefs} )
endforeach()
message( STATUS )
message( STATUS "---------------------------------------------------------" )
message( STATUS "USE_CLANG = ${USE_CLANG}" )
message( STATUS "USE_ANALYZE = ${USE_ANALYZE}" )
message( STATUS "ANALYZE_MEMORY = ${ANALYZE_MEMORY}" )
message( STATUS "ANALYZE_ADDRESS = ${ANALYZE_ADDRESS}" )
message( STATUS "ANALYZE_THREAD = ${ANALYZE_THREAD}" )
@ -39,17 +38,9 @@ message( STATUS "HAVE_RULES = ${HAVE_RULES}" )
message( STATUS )
message( STATUS "Change a value with: cmake -D<Variable>=<Value>" )
message( STATUS )
if(${USE_ANALYZE})
message( STATUS "------------------- Run static analyzer ----------------------" )
message( STATUS "##############################")
message( STATUS "RUN: scan-build make" )
message( STATUS "##############################")
message( STATUS )
endif()
if(${ANALYZE_ADDRESS})
message("##########################################################")
message(STATUS "For better visualization change environment variable: ASAN_SYMBOLIZER_PATH=/path/to/llvm-symbolizer")
message(STATUS "Detect memory leaks, change environment variable: ASAN_OPTIONS=\"detect_leaks=1\"")
message("##########################################################")
endif()

View File

@ -2,6 +2,7 @@ file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")
add_library(simplecpp_objs OBJECT ${srcs} ${hdrs})
# TODO: conflicts with ANALYZE_* options
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_library(simplecpp_objs_sanitized OBJECT EXCLUDE_FROM_ALL ${srcs} ${hdrs})
target_compile_options(simplecpp_objs_sanitized PRIVATE -fsanitize=address)

View File

@ -2,15 +2,22 @@ file(GLOB hdrs "*.h")
file(GLOB srcs "*.cpp")
add_library(tinyxml_objs OBJECT ${srcs} ${hdrs})
# TODO: needs to be fixed upstream
# TODO: need to be fixed upstream
if (CMAKE_CXX_COMPILER_ID MATCHES "GNU")
target_compile_options(tinyxml_objs PRIVATE -Wno-suggest-attribute=format)
# TODO: enable this - was added in Clang 8
#target_compile_options(tinyxml_objs PRIVATE -Wno-extra-semi-stmt)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
target_compile_options(tinyxml_objs PRIVATE -Wno-extra-semi-stmt)
endif()
endif()
# TODO: conflicts with ANALYZE_* options
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_library(tinyxml_objs_sanitized OBJECT EXCLUDE_FROM_ALL ${srcs} ${hdrs})
target_compile_options(tinyxml_objs_sanitized PRIVATE -fsanitize=address)
# TODO: enable this - was added in Clang 8
#target_compile_options(tinyxml_objs_sanitized PRIVATE -Wno-extra-semi-stmt)
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
target_compile_options(tinyxml_objs_sanitized PRIVATE -Wno-extra-semi-stmt)
endif()
endif()

View File

@ -1,7 +1,7 @@
if (BUILD_GUI)
set(CMAKE_AUTOMOC ON)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
if (CMAKE_BUILD_TYPE MATCHES "Release")
add_definitions(-DQT_NO_DEBUG)
add_definitions(-DQT_NO_DEBUG_OUTPUT)
add_definitions(-DQT_NO_WARNING_OUTPUT)
@ -30,9 +30,10 @@ if (BUILD_GUI)
target_link_libraries(cppcheck-gui Qt5::Charts)
endif()
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# TODO: enable this - was added in Clang 8
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
# Q_UNUSED() in generated code
#target_compile_options(cppcheck-gui PRIVATE -Wno-extra-semi-stmt)
target_compile_options(cppcheck-gui PRIVATE -Wno-extra-semi-stmt)
endif()
endif()
install(TARGETS cppcheck-gui RUNTIME DESTINATION ${CMAKE_INSTALL_FULL_BINDIR} COMPONENT applications)

View File

@ -9,7 +9,7 @@ function(build_src output filename)
get_filename_component(file ${filename} NAME)
set(outfile ${CMAKE_CURRENT_BINARY_DIR}/build/mc_${file})
set(${output} ${${output}} ${outfile} PARENT_SCOPE)
if (${USE_MATCHCOMPILER} STREQUAL "Verify")
if (USE_MATCHCOMPILER MATCHES "Verify")
set(verify_option "--verify")
endif()
add_custom_command(
@ -30,7 +30,7 @@ foreach(file ${srcs})
build_src(srcs_build ${file})
endforeach()
if (NOT ${USE_MATCHCOMPILER_OPT} STREQUAL "Off")
if (NOT USE_MATCHCOMPILER_OPT MATCHES "Off")
set(srcs_lib ${srcs_build})
else()
set(srcs_lib ${srcs})

View File

@ -1,6 +1,6 @@
if (BUILD_GUI AND BUILD_TESTS)
set(CMAKE_AUTOMOC ON)
if (${CMAKE_BUILD_TYPE} STREQUAL "Release")
if (CMAKE_BUILD_TYPE MATCHES "Release")
add_definitions(-DQT_NO_DEBUG)
add_definitions(-DQT_NO_DEBUG_OUTPUT)
add_definitions(-DQT_NO_WARNING_OUTPUT)
@ -23,9 +23,10 @@ if (BUILD_GUI AND BUILD_TESTS)
target_include_directories(triage PUBLIC ${PROJECT_SOURCE_DIR}/gui/)
target_link_libraries(triage Qt5::Core Qt5::Gui Qt5::Widgets)
if (CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# TODO: enable this - was added in Clang 8
if (NOT CMAKE_CXX_COMPILER_VERSION VERSION_LESS "8.0.0")
# Q_UNUSED() in generated code
#target_compile_options(triage PRIVATE -Wno-extra-semi-stmt)
target_compile_options(triage PRIVATE -Wno-extra-semi-stmt)
endif()
endif()
set(CMAKE_AUTOMOC OFF)