Skip to content

Commit

Permalink
CMake: Use modern CMake, use math without bounds-checking for speed
Browse files Browse the repository at this point in the history
Signed-off-by: Marcus Müller <[email protected]>
  • Loading branch information
marcusmueller committed Apr 22, 2023
1 parent 4af4b1d commit f373408
Showing 1 changed file with 19 additions and 11 deletions.
30 changes: 19 additions & 11 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
cmake_minimum_required(VERSION 3.25)
project(NBP_jupyter)

project(NBP_jupyter CXX)
set(CMAKE_CXX_STANDARD 17)
FIND_PACKAGE(OpenMP)
if(OPENMP_FOUND)
message("OPENMP FOUND")
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS}")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS}")
set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} ${OpenMP_EXE_LINKER_FLAGS}")
endif()
include_directories(.)

add_executable(NBP_jupyter
simulateFER.cpp
Expand All @@ -18,8 +9,25 @@ add_executable(NBP_jupyter
helpers.cpp
)

find_package(OpenMP)
if(OPENMP_FOUND)
target_link_libraries(NBP_jupyter PUBLIC OpenMP::OpenMP_CXX)
endif()


if(MSVC)
target_compile_options(NBP_jupyter PRIVATE /W4 /WX)
else()
target_compile_options(NBP_jupyter PRIVATE -Wall -Wextra -Wpedantic -ffast-math)
target_compile_options(NBP_jupyter PRIVATE -Wall -Wextra -Wpedantic)
endif()

include(CheckCXXCompilerFlag)
check_cxx_compiler_flag("-ffast-math" fastmath)
if(fastmath)
target_compile_options(NBP_jupyter PRIVATE -ffast-math)
endif()

check_cxx_compiler_flag("-funsafe-math-optimizations" veryfastmath)
if(veryfastmath)
target_compile_options(NBP_jupyter PRIVATE -funsafe-math-optimizations)
endif()

0 comments on commit f373408

Please sign in to comment.