diff --git a/blast/CMakeLists.txt b/blast/CMakeLists.txt index ab24430..435993a 100644 --- a/blast/CMakeLists.txt +++ b/blast/CMakeLists.txt @@ -34,7 +34,26 @@ if(NOT TARGET nlopt) if(NOT DEFINED Python_VERSION_MINOR) set(Python_VERSION_MINOR "0") endif() + + # ====================================================================== + # FIX: Force NLopt to build as a static library to prevent missing DLLs + # ====================================================================== + set(NLOPT_CXX ON CACHE BOOL "Build NLopt with C++ compiler" FORCE) + + set(OLD_BUILD_SHARED ${BUILD_SHARED_LIBS}) + set(BUILD_SHARED_LIBS OFF CACHE BOOL "Build static libraries" FORCE) + add_subdirectory(extern/nlopt EXCLUDE_FROM_ALL) + + # Restore the original global setting so you don't force the outer + # project's other dependencies to be static unexpectedly + set(BUILD_SHARED_LIBS ${OLD_BUILD_SHARED} CACHE BOOL "Build static libraries" FORCE) + + # Keep the interface include fix from earlier + target_include_directories(nlopt INTERFACE + $ + $ + ) endif() # -------------------------------------------------------------------------- diff --git a/cmake/BlastConfig.cmake.in b/cmake/BlastConfig.cmake.in index 44d8f19..cd99b6a 100644 --- a/cmake/BlastConfig.cmake.in +++ b/cmake/BlastConfig.cmake.in @@ -2,4 +2,25 @@ include("${CMAKE_CURRENT_LIST_DIR}/BlastTargets.cmake") -check_required_components(Blast) \ No newline at end of file +check_required_components(Blast) + +@PACKAGE_INIT@ + +include("${CMAKE_CURRENT_LIST_DIR}/BlastTargets.cmake") + +check_required_components(Blast) + +# --------------------------------------------------------------------------- +# Helper: call blast_copy_runtime_dlls(your_target) after find_package(Blast) +# to automatically copy nlopt.dll next to your executable on Windows. +# --------------------------------------------------------------------------- +macro(blast_copy_runtime_dlls target) + if(WIN32) + add_custom_command(TARGET ${target} POST_BUILD + COMMAND ${CMAKE_COMMAND} -E copy_if_different + $ + $ + COMMENT "Copying nlopt.dll for ${target}" + ) + endif() +endmacro() \ No newline at end of file