Skip to content

Commit

Permalink
Restored CMake 2.8.11 minimum version
Browse files Browse the repository at this point in the history
Popular and modern Linux distribuitions have CMake 2.8.12
(sometimes 2.8.11). So these version must be supported. For this use
old FindCXX11 find module to get correct compiler flags.
  • Loading branch information
drizt authored and vinipsmaker committed Apr 12, 2015
1 parent e2671eb commit edc23cd
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 5 deletions.
10 changes: 9 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
12 changes: 10 additions & 2 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 12 additions & 2 deletions src/tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
Expand Down

0 comments on commit edc23cd

Please sign in to comment.