ref: b8a8adb6da85cd4c79f5c47ccee728fa03cf09a0
parent: a34a256d427468ec74ead49d48647317cae0e0c0
author: Cameron Cawley <ccawley2011@gmail.com>
date: Mon Sep 6 17:11:47 EDT 2021
Enable OpenMP in CMake builds
--- a/SDL_Examples/CMakeLists.txt
+++ b/SDL_Examples/CMakeLists.txt
@@ -1,4 +1,5 @@
find_package(SDL QUIET)
+find_package(OpenMP QUIET)
if(SDL_FOUND)
@@ -14,11 +15,14 @@
foreach(DEMO ${demo_names})
set(DEMO_NAME "sdl_${DEMO}")
add_executable(${DEMO_NAME} ${DEMO}.c)
- target_link_libraries(${DEMO_NAME} ${TINYGL_LIB} ${M_LIBRARY} ${SDL_LIBRARY})
+ target_link_libraries(${DEMO_NAME} PRIVATE ${TINYGL_LIB} ${M_LIBRARY} ${SDL_LIBRARY})
target_include_directories(${DEMO_NAME} PUBLIC ${SDL_INCLUDE_DIR})
if(NOT MSVC)
target_compile_options(${DEMO_NAME} PRIVATE -O3 -DNDEBUG -pedantic -march=native -Wall)
endif(NOT MSVC)
+ if(OPENMP_C_FOUND)
+ target_link_libraries(${DEMO_NAME} PRIVATE OpenMP::OpenMP_C)
+ endif(OPENMP_C_FOUND)
endforeach()
set(TINYGL_RESOURCES
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -28,6 +28,8 @@
ztriangle.c
)
+find_package(OpenMP)
+
if(TINYGL_BUILD_SHARED)
add_library(tinygl SHARED ${tinygl_srcs})
target_include_directories(tinygl PUBLIC ${CMAKE_CURRENT_SOURCE_DIR}/../include)
@@ -38,6 +40,9 @@
if(NOT MSVC)
target_compile_options(tinygl PRIVATE -O3 -DNDEBUG -pedantic -march=native -Wall -Wno-unused-function)
endif(NOT MSVC)
+ if(OPENMP_C_FOUND)
+ target_link_libraries(tinygl PUBLIC OpenMP::OpenMP_C)
+ endif(OPENMP_C_FOUND)
endif(TINYGL_BUILD_SHARED)
if(TINYGL_BUILD_STATIC)
@@ -50,6 +55,9 @@
if(NOT MSVC)
target_compile_options(tinygl-static PRIVATE -O3 -DNDEBUG -pedantic -march=native -Wall -Wno-unused-function)
endif(NOT MSVC)
+ if(OPENMP_C_FOUND)
+ target_link_libraries(tinygl-static PUBLIC OpenMP::OpenMP_C)
+ endif(OPENMP_C_FOUND)
endif(TINYGL_BUILD_STATIC)
# Local Variables: