Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions blast/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/extern/nlopt/src/api>
$<BUILD_INTERFACE:${CMAKE_CURRENT_BINARY_DIR}/extern/nlopt>
)
endif()

# --------------------------------------------------------------------------
Expand Down
23 changes: 22 additions & 1 deletion cmake/BlastConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,25 @@

include("${CMAKE_CURRENT_LIST_DIR}/BlastTargets.cmake")

check_required_components(Blast)
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
$<TARGET_FILE:Blast::nlopt>
$<TARGET_FILE_DIR:${target}>
COMMENT "Copying nlopt.dll for ${target}"
)
endif()
endmacro()
Loading