Skip to content

Commit

Permalink
Added compile flags for MacOS
Browse files Browse the repository at this point in the history
  • Loading branch information
eg0000r-pub committed Feb 15, 2024
1 parent c1665ec commit e5e7b04
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,18 @@ include(CTest)

set(ERROR_ON_WARN OFF)

set(CMAKE_LIBGRAN_USE_OMP ON)
set(CMAKE_LIBGRAN_USE_OMP OFF)

if (${CMAKE_LIBGRAN_USE_OMP})
add_compile_definitions(LIBGRAN_USE_OMP)
endif ()

if (${APPLE})
set(CMAKE_CXX_FLAGS "-Wall -Wextra -O3 -fopenmp")
set(CMAKE_CXX_FLAGS "-Wall -Wextra -O3 -fopenmp -flto -march=native")
if (${ERROR_ON_WARN})
set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
endif ()
set(LIBRARY_LIST "-lopm -flto")
endif ()

if (${MSVC})
Expand All @@ -26,6 +27,7 @@ if (${MSVC})
if (${ERROR_ON_WARN})
set(CMAKE_CXX_FLAGS "/Wx ${CMAKE_CXX_FLAGS}")
endif ()
set(LIBRARY_LIST "")
endif ()

if (${CMAKE_COMPILER_IS_GNUCXX})
Expand All @@ -34,6 +36,7 @@ if (${CMAKE_COMPILER_IS_GNUCXX})
set(CMAKE_CXX_FLAGS "-Werror ${CMAKE_CXX_FLAGS}")
endif ()
find_package(TBB REQUIRED)
set(LIBRARY_LIST PRIVATE TBB::tbb)
endif ()

# SYSTEM keyword suppressed warnings from included headers
Expand All @@ -58,14 +61,14 @@ add_executable(alt_sintered_test test/alt_sintered.cpp writer.cpp test/mass_dist
add_executable(sintered_2_test test/sintered_2.cpp writer.cpp)

if (${CMAKE_COMPILER_IS_GNUCXX})
target_link_libraries(libgran PRIVATE TBB::tbb)
target_link_libraries(contact_test PRIVATE TBB::tbb)
target_link_libraries(hamaker_test PRIVATE TBB::tbb)
target_link_libraries(hamaker_2_test PRIVATE TBB::tbb)
target_link_libraries(hamaker_3_test PRIVATE TBB::tbb)
target_link_libraries(sintered_test PRIVATE TBB::tbb)
target_link_libraries(sintered_2_test PRIVATE TBB::tbb)
target_link_libraries(alt_sintered_test PRIVATE TBB::tbb)
target_link_libraries(libgran ${LIBRARY_LIST})
target_link_libraries(contact_test ${LIBRARY_LIST})
target_link_libraries(hamaker_test ${LIBRARY_LIST})
target_link_libraries(hamaker_2_test ${LIBRARY_LIST})
target_link_libraries(hamaker_3_test ${LIBRARY_LIST})
target_link_libraries(sintered_test ${LIBRARY_LIST})
target_link_libraries(sintered_2_test ${LIBRARY_LIST})
target_link_libraries(alt_sintered_test ${LIBRARY_LIST})
endif ()

add_test(NAME contact_test COMMAND ${CMAKE_BINARY_DIR}/contact_test)
Expand Down

0 comments on commit e5e7b04

Please sign in to comment.