Skip to content

Commit

Permalink
build: set C++ standard with cmake (#410)
Browse files Browse the repository at this point in the history
It turns out that where the standard flag appears in the command line
does not affect compiler code generation.

Partial revert of commit cfc81ea.
  • Loading branch information
jnooree authored Nov 21, 2024
1 parent c203724 commit f96ce3e
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 16 deletions.
5 changes: 3 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,9 @@ elseif(NOT CMAKE_CXX_COMPILER_ID MATCHES "GNU")
"Please use clang or gcc as a compiler.")
endif()

# for math optimization flags
string(APPEND CMAKE_CXX_FLAGS " -std=c++17")
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)

set(NURI_GLOBAL_OPTFLAGS " -${NURI_OPTIMIZATION_LEVEL}")
Expand Down
11 changes: 0 additions & 11 deletions cmake/NuriKitUtils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,12 +86,6 @@ function(nuri_get_version)
set(NURI_REF "${NURI_REF}" PARENT_SCOPE)
endfunction()

macro(nuri_set_cxx_standard)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_EXTENSIONS OFF)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
endmacro()

function(nuri_make_available_deponly target)
include(FetchContent)

Expand All @@ -117,8 +111,6 @@ function(target_system_include_directories target)
endfunction()

function(find_or_fetch_eigen)
nuri_set_cxx_standard()

set(CMAKE_POLICY_DEFAULT_CMP0077 NEW)
set(BUILD_TESTING OFF)
set(EIGEN_BUILD_DOC OFF)
Expand All @@ -141,7 +133,6 @@ function(find_or_fetch_eigen)
endfunction()

function(find_or_fetch_spectra)
nuri_set_cxx_standard()
set(BUILD_TESTING OFF)

find_package(Spectra 1.0 QUIET)
Expand All @@ -162,7 +153,6 @@ function(find_or_fetch_spectra)
endfunction()

function(find_or_fetch_pybind11)
nuri_set_cxx_standard()
set(BUILD_TESTING OFF)

# FindPythonInterp/FindPythonLibs deprecated since cmake 3.12
Expand All @@ -188,7 +178,6 @@ function(find_or_fetch_pybind11)
endfunction()

function(handle_boost_dependency target)
nuri_set_cxx_standard()
set(BUILD_TESTING OFF)

# FindBoost deprecated since cmake 3.30
Expand Down
3 changes: 0 additions & 3 deletions third-party/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
# SPDX-License-Identifier: Apache-2.0
#

include(NuriKitUtils)
nuri_set_cxx_standard()

# Don't fail build on warnings from third-party code.
add_compile_options(-Wno-error)

Expand Down

0 comments on commit f96ce3e

Please sign in to comment.