Skip to content

Commit

Permalink
casadi: use OpenMP::OpenMP_CXX target for linking
Browse files Browse the repository at this point in the history
  • Loading branch information
valgur committed Aug 10, 2024
1 parent 36c2e82 commit 0e5b2c5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
3 changes: 3 additions & 0 deletions recipes/casadi/all/conandata.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,6 @@ patches:
patch_description: "Fix target_compile_definitions() being used to set CFLAGS"
patch_source: "https://github.com/casadi/casadi/pull/3511"
patch_type: "bugfix"
- patch_file: "patches/002-fix-openmp-linking.patch"
patch_description: "Don't add OpenMP_CXX_FLAGS to global CMAKE_CXX_FLAGS"
patch_type: "portability"
21 changes: 21 additions & 0 deletions recipes/casadi/all/patches/002-fix-openmp-linking.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
Fix try_compile() failing due to OpenMP_CXX_FLAGS flags being added to CMAKE_CXX_FLAGS and libomp not being found.

--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,4 +1,4 @@
-cmake_minimum_required(VERSION 3.10.2)
+cmake_minimum_required(VERSION 3.15)
project(casadi C CXX)

set(CASADI_MAJOR_VERSION 3)
@@ -303,8 +303,8 @@
if(WITH_OPENMP)
find_package(OpenMP REQUIRED)
if(OPENMP_FOUND)
- set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${OpenMP_CXX_FLAGS} -DWITH_OPENMP")
- set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${OpenMP_C_FLAGS} -DWITH_OPENMP")
+ link_libraries($<$<LINK_LANGUAGE:C>:OpenMP::OpenMP_C>)
+ link_libraries($<$<LINK_LANGUAGE:CXX>:OpenMP::OpenMP_CXX>)
endif()
endif()

0 comments on commit 0e5b2c5

Please sign in to comment.