Skip to content

Commit

Permalink
cmake to set compiler flags for newer c++ features for the test compi…
Browse files Browse the repository at this point in the history
…lation
  • Loading branch information
steffennissen committed Nov 1, 2015
1 parent cbf0a48 commit cdeee86
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ install (FILES

################# compile tests ################

#include_directories("${CMAKE_CURRENT_BINARY_DIR}/lib/googletest/include;${CMAKE_CURRENT_BINARY_DIR}/src/include")
ADD_SUBDIRECTORY( lib/googletest )
ADD_SUBDIRECTORY( tests )

Expand Down
11 changes: 9 additions & 2 deletions tests/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,22 @@ include(CheckCXXCompilerFlag)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/src/include)
INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR}/lib/googletest/include)

CHECK_CXX_COMPILER_FLAG("-std=c++14" COMPILER_SUPPORTS_CXX14)
CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11)
CHECK_CXX_COMPILER_FLAG("-std=c++0x" COMPILER_SUPPORTS_CXX0X)
if(COMPILER_SUPPORTS_CXX11)
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++14 support.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
elseif(COMPILER_SUPPORTS_CXX11)
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++11 support.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
elseif(COMPILER_SUPPORTS_CXX0X)
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has C++0x support.")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x")
else()
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++11 support. Please use a different C++ compiler.")
message(STATUS "The compiler ${CMAKE_CXX_COMPILER} has no C++0x, C++11 or C++14 support. FANN will still work with no problem, but the tests will not be able to compile.")
return()
endif()

ADD_EXECUTABLE(fann_tests main.cpp fann_test.cpp fann_test_data.cpp fann_test_train.cpp)
target_link_libraries(fann_tests gtest doublefann)
target_link_libraries(fann_tests gtest doublefann)

0 comments on commit cdeee86

Please sign in to comment.