Skip to content

CMake: rely on compile features to inject at least C++11 #563

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -341,9 +341,6 @@ add_subdirectory(src)
add_subdirectory(include/fcl)

set(PKG_DESC "Flexible Collision Library")
if(NOT MSVC)
set(PKG_CFLAGS "-std=c++11")
endif()
configure_file(fcl.pc.in fcl.pc @ONLY)

install(FILES "${CMAKE_CURRENT_BINARY_DIR}/fcl.pc"
Expand Down
10 changes: 5 additions & 5 deletions CMakeModules/CompilerSettings.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,15 @@

# GCC
if(CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-std=c++11 -W -Wall -Wextra -Wpedantic)
add_definitions(-W -Wall -Wextra -Wpedantic)
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(-Werror)
endif()
endif()

# Clang
if(CMAKE_CXX_COMPILER_ID STREQUAL "Clang")
add_definitions(-std=c++11 -W -Wall -Wextra)
add_definitions(-W -Wall -Wextra)
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(-Werror)
endif()
Expand All @@ -53,7 +53,7 @@ if(CMAKE_CXX_COMPILER_ID STREQUAL "AppleClang")
if (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 6.1)
message(FATAL_ERROR "AppleClang version must be at least 6.1!")
endif()
add_definitions(-std=c++11 -W -Wall -Wextra)
add_definitions(-W -Wall -Wextra)
if(FCL_TREAT_WARNINGS_AS_ERRORS)
add_definitions(-Werror)
endif()
Expand All @@ -77,7 +77,7 @@ else()
set(IS_ICPC 0)
endif()
if(IS_ICPC)
add_definitions(-std=c++11 -wd191 -wd411 -wd654 -wd1125 -wd1292 -wd1565 -wd1628 -wd2196)
add_definitions(-wd191 -wd411 -wd654 -wd1125 -wd1292 -wd1565 -wd1628 -wd2196)
set(CMAKE_AR "xiar" CACHE STRING "Intel archiver" FORCE)
set(CMAKE_CXX_FLAGS "-pthread" CACHE STRING "Default compile flags" FORCE)
set(CMAKE_CXX_FLAGS_RELEASE "-O3 -DNDEBUG"
Expand All @@ -97,7 +97,7 @@ else()
set(IS_XLC 0)
endif()
if(IS_XLC)
add_definitions(-std=c++11 -qpic -q64 -qmaxmem=-1)
add_definitions(-qpic -q64 -qmaxmem=-1)
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -q64")
set(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -q64")
endif()
Expand Down
2 changes: 1 addition & 1 deletion fcl.pc.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,4 @@ Description: @PKG_DESC@
Version: @FCL_VERSION@
Requires: @PKG_EXTERNAL_DEPS@
Libs: -L${libdir} -l@PROJECT_NAME@
Cflags: @PKG_CFLAGS@ -I${includedir}
Cflags: -I${includedir}
2 changes: 2 additions & 0 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ else()
add_library(${PROJECT_NAME} SHARED ${FCL_HEADERS} ${FCL_SOURCE_CODE})
endif()

target_compile_features(${PROJECT_NAME} PUBLIC cxx_std_11)

# Be sure to pass to the consumer the set of SIMD used in the compilation
target_compile_options(${PROJECT_NAME} PUBLIC ${SSE_FLAGS})

Expand Down
4 changes: 2 additions & 2 deletions test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ execute_process(COMMAND cmake -E make_directory ${CMAKE_BINARY_DIR}/test_results
include_directories(${GTEST_INCLUDE_DIRS})

add_library(test_fcl_utility test_fcl_utility.cpp)
target_link_libraries(test_fcl_utility fcl)
target_link_libraries(test_fcl_utility PUBLIC fcl)

# test file list
set(tests
Expand Down Expand Up @@ -75,7 +75,7 @@ macro(add_fcl_test test_file_name)
# Get the name (i.e. bla.cpp => bla)
get_filename_component(test_name ${ARGV} NAME_WE)
add_executable(${test_name} ${ARGV})
target_link_libraries(${test_name} fcl test_fcl_utility gtest)
target_link_libraries(${test_name} PRIVATE fcl test_fcl_utility gtest)
add_test(${test_name} ${EXECUTABLE_OUTPUT_PATH}/${test_name})
endmacro(add_fcl_test)

Expand Down