Skip to content

Commit c3032dc

Browse files
committed
switch to static build for windows
1 parent 49e1398 commit c3032dc

3 files changed

Lines changed: 12 additions & 9 deletions

File tree

.github/workflows/win-build.yml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ jobs:
6363
-DCMAKE_BUILD_TYPE=Release `
6464
-DCMAKE_PREFIX_PATH="$env:HIGHS_DIR" `
6565
-DCMAKE_INSTALL_PREFIX="${{ github.workspace }}\dist" `
66+
-DBUILD_SHARED_LIBS=OFF `
6667
-DJRES_VERSION="${{ inputs.version }}"
6768
6869
- name: Add Build Dir to PATH
@@ -121,15 +122,10 @@ jobs:
121122
Copy-Item "dist\bin\jres_solver.exe" -Destination "$pkg\bin\"
122123
Copy-Item "dist\bin\jres_formatter.exe" -Destination "$pkg\bin\"
123124
124-
# Library (Handle DLLs and LIBs)
125-
# Copy import libraries (.lib) to lib folder
125+
# Library (static)
126126
if (Test-Path "dist\lib\jres_solver.lib") {
127127
Copy-Item "dist\lib\jres_solver.lib" -Destination "$pkg\lib\"
128128
}
129-
# Copy runtime libraries (.dll) to bin folder (typical windows convention)
130-
if (Test-Path "dist\bin\jres_solver.dll") {
131-
Copy-Item "dist\bin\jres_solver.dll" -Destination "$pkg\bin\"
132-
}
133129
134130
# Specific Header
135131
Copy-Item "dist\include\jres_solver\jres_solver.hpp" -Destination "$pkg\include\jres_solver\"

CMakeLists.txt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,11 @@ set_target_properties(jres_solver_lib PROPERTIES OUTPUT_NAME "jres_solver")
166166

167167
if(WIN32)
168168
target_sources(jres_solver_lib PRIVATE ${VERSION_RC})
169-
# Only export symbols if we are actually building shared
169+
170170
if(BUILD_SHARED_LIBS)
171171
target_compile_definitions(jres_solver_lib PRIVATE JRES_SOLVER_EXPORTS)
172+
else()
173+
target_compile_definitions(jres_solver_lib PUBLIC JRES_STATIC)
172174
endif()
173175
endif()
174176

include/jres_solver/jres_solver.hpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,15 @@
1313
#define JRES_SOLVER_HPP
1414

1515
#if defined(_WIN32)
16-
// Windows/MSVC: Use __declspec(dllexport/dllimport)
17-
#ifdef JRES_SOLVER_EXPORTS
16+
// Windows/MSVC: Handle DLL exports, imports, AND static builds
17+
#if defined(JRES_STATIC)
18+
// Static build: No special attributes needed
19+
#define JRES_SOLVER_API
20+
#elif defined(JRES_SOLVER_EXPORTS)
21+
// Building the DLL: Export symbols
1822
#define JRES_SOLVER_API __declspec(dllexport)
1923
#else
24+
// Using the DLL: Import symbols
2025
#define JRES_SOLVER_API __declspec(dllimport)
2126
#endif
2227
#else

0 commit comments

Comments
 (0)