diff --git a/CMakeLists.txt b/CMakeLists.txt index f2dab684ee409bac5e0b339c4b781f7f2169ebef..b42df5d20be7ba5e19435179fdc8115ff378a21d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -127,40 +127,8 @@ if(NOT QT_MKSPEC MATCHES "winrt") ) endif() -if(${CMAKE_BUILD_TYPE} MATCHES "Debug") - include(CTest) - enable_testing() - add_definitions(-DUNITTEST_BUILD) -endif() - -if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") - # clang and AppleClang - add_compile_options( - -Wall - -Wextra - - -Wno-address-of-packed-member # ignore for mavlink - ) - -elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") - # GCC - if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9) - add_compile_options(-fdiagnostics-color=always) - endif() - - add_compile_options( - -Wall - -Wextra - ) - -elseif (WIN32) - - add_definitions(-D_USE_MATH_DEFINES) - add_compile_options( - /wd4244 # warning C4244: '=': conversion from 'double' to 'float', possible loss of data - ) - -endif() +# Sets the default flags for compilation and linking. +include(CompileOptions) # TODO: get qtquick compiler working #qtquick_compiler_add_resources(QGC_RESOURCES ${QGC_RESOURCES} diff --git a/cmake/CompileOptions.cmake b/cmake/CompileOptions.cmake new file mode 100644 index 0000000000000000000000000000000000000000..e4746f3e67231aac4d93165ad86b47cbebb0dde3 --- /dev/null +++ b/cmake/CompileOptions.cmake @@ -0,0 +1,30 @@ + +if(${CMAKE_BUILD_TYPE} MATCHES "Debug") + include(CTest) + enable_testing() + add_definitions(-DUNITTEST_BUILD) +endif() + +if (CMAKE_CXX_COMPILER_ID MATCHES "Clang") + # clang and AppleClang + add_compile_options( + -Wall + -Wextra + -Wno-address-of-packed-member # ignore for mavlink + ) +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") + # GCC + if(CMAKE_CXX_COMPILER_VERSION VERSION_GREATER 4.9) + add_compile_options(-fdiagnostics-color=always) + endif() + + add_compile_options( + -Wall + -Wextra + ) +elseif (WIN32) + add_definitions(-D_USE_MATH_DEFINES) + add_compile_options( + /wd4244 # warning C4244: '=': conversion from 'double' to 'float', possible loss of data + ) +endif()