Skip to content

Commit

Permalink
build: set C/C++ standard before checking compiler flags
Browse files Browse the repository at this point in the history
Otherwise CMake would try to detect compiler features/support without
the required language standard - this may impact results.
  • Loading branch information
echeresh committed Apr 12, 2019
1 parent f2cef86 commit a1c5b34
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,11 @@ set(CMAKE_SRC_CCXX_FLAGS) # SRC specifics
set(CMAKE_EXAMPLE_CCXX_FLAGS) # EXAMPLE specifics
set(CMAKE_TEST_CCXX_FLAGS) # TESTS specifics

if(UNIX OR MINGW)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c99")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")
endif()

include(GNUInstallDirs)
include(CMakePackageConfigHelpers)

Expand Down
3 changes: 1 addition & 2 deletions cmake/platform.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,7 @@ elseif(UNIX OR MINGW)
append(CMAKE_CCXX_FLAGS "-Wall -Wno-unknown-pragmas")
append_if(MKLDNN_WERROR CMAKE_CCXX_FLAGS "-Werror")
append(CMAKE_CCXX_FLAGS "-fvisibility=internal")
append(CMAKE_C_FLAGS "-std=c99")
append(CMAKE_CXX_FLAGS "-std=c++11 -fvisibility-inlines-hidden")
append(CMAKE_CXX_FLAGS "-fvisibility-inlines-hidden")
# compiler specific settings
if(CMAKE_CXX_COMPILER_ID MATCHES "Clang")
# Clang cannot vectorize some loops with #pragma omp simd and gets
Expand Down

0 comments on commit a1c5b34

Please sign in to comment.