Skip to content

Commit

Permalink
Added temporary workaround until CMA-ES/libcmaes#238 is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Philipp Basler committed May 25, 2022
1 parent fef4ef8 commit c5ad00b
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions tools/cmake/CMAES.cmake
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
find_package(OpenMP REQUIRED)
find_package(libcmaes 0.10 QUIET)
if(NOT libcmaes_FOUND)
set(BSMPT_CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}")
set(BSMPT_CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG}")
set(BSMPT_CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE}")
set(EXPORT_CMAES TRUE)
FetchContent_Declare(
libcmaes
Expand All @@ -21,6 +24,23 @@ find_package(libcmaes 0.10 QUIET)
"${libcmaes_SOURCE_DIR}/*"
)
endif()

## WORKAROUND for https://github.com/phbasler/BSMPT/issues/72 until the PR is fixed
string(REPLACE " " ";" REPLACED_FLAGS ${BSMPT_CMAKE_CXX_FLAGS})
string(REPLACE " " ";" REPLACED_FLAGS_RELEASE ${BSMPT_CMAKE_CXX_FLAGS_RELEASE})
string(REPLACE " " ";" REPLACED_FLAGS_DEBUG ${BSMPT_CMAKE_CXX_FLAGS_DEBUG})
target_compile_options(cmaes PUBLIC ${REPLACED_FLAGS})
if(CMAKE_BUILD_TYPE MATCHES RELEASE)
target_compile_options(cmaes PUBLIC ${REPLACED_FLAGS_RELEASE})
endif()
if(CMAKE_BUILD_TYPE MATCHES DEBUG)
target_compile_options(cmaes PUBLIC ${REPLACED_FLAGS_DEBUG})
endif()
set(CMAKE_CXX_FLAGS "${BSMPT_CMAKE_CXX_FLAGS} ${CMAKE_CXX_FLAGS}")
set(CMAKE_CXX_FLAGS_DEBUG "${BSMPT_CMAKE_CXX_FLAGS_DEBUG} ${CMAKE_CXX_FLAGS_DEBUG}")
set(CMAKE_CXX_FLAGS_RELEASE "${BSMPT_CMAKE_CXX_FLAGS_RELEASE} ${CMAKE_CXX_FLAGS_RELEASE}")
## WORKAROUND end

set(libcmaes_FOUND TRUE)
else()
set(CodeCoverageExcludesFromOtherPkgs
Expand Down

0 comments on commit c5ad00b

Please sign in to comment.