Browse Source

Fix build with CMake < 3.0

pull/53/head
Daniel Scharrer 10 years ago
parent
commit
b3ca90e529
  1. 2
      cmake/CXX11Check.cmake
  2. 8
      cmake/CompileCheck.cmake

2
cmake/CXX11Check.cmake

@ -56,7 +56,7 @@ function(check_cxx11 CHECK RESULTVAR)
set(file "${CXX11_CHECK_DIR}/check-cxx11-${check}.cpp")
check_compile(result "${file}" "${CHECK}" "C++11 feature")
endif()
if(result STREQUAL "")
if(NOT DEFINED result OR result STREQUAL "")
set(${RESULTVAR} OFF PARENT_SCOPE)
else()
set(${RESULTVAR} ON PARENT_SCOPE)

8
cmake/CompileCheck.cmake

@ -17,6 +17,10 @@
# misrepresented as being the original software.
# 3. This notice may not be removed or altered from any source distribution.
# Note: In CMake before 3.0 set(var "" PARENT_SCOPE) *unsets* the variable in the
# parent scope instead of setting it to the empty string.
# This means if(var STREQUAL "") will be false since var is not defined and thus not expanded.
function(check_compile RESULT FILE FLAG TYPE)
string(REGEX REPLACE "[^a-zA-Z0-9_][^a-zA-Z0-9_]*" "-" cachevar "${TYPE}-${FLAG}")
@ -142,7 +146,7 @@ function(add_cxxflag FLAG)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${RESULT}" PARENT_SCOPE)
if(RESULT STREQUAL "")
if(NOT DEFINED RESULT OR RESULT STREQUAL "")
set(FLAG_FOUND 0 PARENT_SCOPE)
else()
set(FLAG_FOUND 1 PARENT_SCOPE)
@ -158,7 +162,7 @@ function(add_ldflag FLAG)
set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} ${RESULT}" PARENT_SCOPE)
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} ${RESULT}" PARENT_SCOPE)
if(RESULT STREQUAL "")
if(NOT DEFINED RESULT OR RESULT STREQUAL "")
set(FLAG_FOUND 0 PARENT_SCOPE)
else()
set(FLAG_FOUND 1 PARENT_SCOPE)

Loading…
Cancel
Save