diff --git a/CMakeLists.txt b/CMakeLists.txt index 2c93560..f758725 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,10 +9,18 @@ set(TUFAO_VERSION ${TUFAO_VERSION_MAJOR}.${TUFAO_VERSION_MINOR}.${TUFAO_VERSION_ set(TUFAO_BRIEF "An asynchronous web framework for C++ built on top of Qt") # Dependencies -cmake_minimum_required(VERSION 3.1.0) +cmake_minimum_required(VERSION 2.8.11) find_package(Qt5Core REQUIRED) find_package(Qt5Network REQUIRED) +# CMake since 3.1 has ability to use particular C/C++ standarts. +# For versions before 3.1 use FindCXX11 module as fallback. +if("${CMAKE_VERSION}" VERSION_LESS "3.1") + set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/modules" ${CMAKE_MODULE_PATH}) + find_package(CXX11 REQUIRED) + set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${CXX11_FLAGS}") +endif() + get_target_property(QMAKE_EXECUTABLE Qt5::qmake LOCATION) function(QUERY_QMAKE VAR RESULT) exec_program("${QMAKE_EXECUTABLE}" ARGS "-query ${VAR}" RETURN_VALUE return_code OUTPUT_VARIABLE output) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 85560ab..c63c636 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -43,11 +43,19 @@ set_target_properties( VERSION ${TUFAO_VERSION} VS_KEYWORD Qt4VSv1.0 AUTOMOC ON - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED ON INSTALL_NAME_DIR "${CMAKE_INSTALL_PREFIX}/${libdir}" ) +# CXX_STANDARD was introduced in CMake 3.1 +if("${CMAKE_VERSION}" VERSION_GREATER "3.0") + set_target_properties( + "${TUFAO_LIBRARY}" + PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + ) +endif() + if("${CMAKE_VERSION}" VERSION_LESS "2.8.12") target_include_directories("${TUFAO_LIBRARY}" INTERFACE "${CMAKE_INSTALL_PREFIX}/${includedir}") install(TARGETS "${TUFAO_LIBRARY}" EXPORT "${TUFAO_LIBRARY}-export" diff --git a/src/tests/CMakeLists.txt b/src/tests/CMakeLists.txt index 2c1db9e..aa57f22 100644 --- a/src/tests/CMakeLists.txt +++ b/src/tests/CMakeLists.txt @@ -25,9 +25,19 @@ macro(setup_test_target target) "${target}" PROPERTIES AUTOMOC ON - CXX_STANDARD 11 - CXX_STANDARD_REQUIRED ON ) + + # CXX_STANDARD was introduced in CMake 3.1 + if("${CMAKE_VERSION}" VERSION_GREATER "3.0") + set_target_properties( + "${target}" + PROPERTIES + CXX_STANDARD 11 + CXX_STANDARD_REQUIRED ON + ) +endif() + + target_link_libraries("${target}" "${TUFAO_LIBRARY}") add_test(NAME "${target}"