Skip to content

Commit 6fb52e8

Browse files
author
Philipp Basler
committed
Added temporary workaround until CMA-ES/libcmaes#238 is fixed
1 parent 94903ea commit 6fb52e8

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

tools/cmake/CMAES.cmake

+20
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
find_package(OpenMP REQUIRED)
22
find_package(libcmaes 0.10 QUIET)
33
if(NOT libcmaes_FOUND)
4+
set(BSMPT_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
5+
set(BSMPT_CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
6+
set(BSMPT_CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
47
set(EXPORT_CMAES TRUE)
58
FetchContent_Declare(
69
libcmaes
@@ -21,6 +24,23 @@ find_package(libcmaes 0.10 QUIET)
2124
"${libcmaes_SOURCE_DIR}/*"
2225
)
2326
endif()
27+
28+
## WORKAROUND for https://github.com/phbasler/BSMPT/issues/72 until the PR is fixed
29+
string(REPLACE " " ";" REPLACED_FLAGS ${BSMPT_CMAKE_CXX_FLAGS})
30+
string(REPLACE " " ";" REPLACED_FLAGS_RELEASE ${BSMPT_CMAKE_CXX_FLAGS_RELEASE})
31+
string(REPLACE " " ";" REPLACED_FLAGS_DEBUG ${BSMPT_CMAKE_CXX_FLAGS_DEBUG})
32+
target_compile_options(cmaes PUBLIC ${REPLACED_FLAGS})
33+
if(CMAKE_BUILD_TYPE MATCHES RELEASE)
34+
target_compile_options(cmaes PUBLIC ${REPLACED_FLAGS_RELEASE})
35+
endif()
36+
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
37+
target_compile_options(cmaes PUBLIC ${REPLACED_FLAGS_DEBUG})
38+
endif()
39+
set(CMAKE_CXX_FLAGS "${BSMPT_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
40+
set(CMAKE_CXX_FLAGS_DEBUG "${BSMPT_CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}")
41+
set(CMAKE_CXX_FLAGS_RELEASE "${BSMPT_CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}")
42+
## WORKAROUND end
43+
2444
set(libcmaes_FOUND TRUE)
2545
else()
2646
set(CodeCoverageExcludesFromOtherPkgs

0 commit comments

Comments
 (0)