Skip to content

Commit 44d553f

Browse files
committed
disable CUPDLPX_BUILD_CLI on windows
1 parent 03bdf79 commit 44d553f

1 file changed

Lines changed: 34 additions & 14 deletions

File tree

CMakeLists.txt

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ add_library(cupdlpx_compile_flags INTERFACE)
4343
if(MSVC)
4444
target_compile_options(cupdlpx_compile_flags INTERFACE
4545
$<$<OR:$<COMPILE_LANGUAGE:C>,$<COMPILE_LANGUAGE:CXX>>:/O2 /W4 /Zi>
46-
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler "/O2 /W4 /Zi">
46+
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/O2>
47+
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/W4>
48+
$<$<COMPILE_LANGUAGE:CUDA>:-Xcompiler=/Zi>
4749
)
4850
target_compile_definitions(cupdlpx_compile_flags INTERFACE
4951
_CRT_SECURE_NO_WARNINGS
@@ -74,37 +76,43 @@ cmake_dependent_option(CUPDLPX_BUILD_PYTHON "Build the cuPDLPx Python bindings"
7476
cmake_dependent_option(CUPDLPX_BUILD_CLI "Build the cuPDLPx command-line executable" ON "CUPDLPX_BUILD_STATIC_LIB" OFF)
7577
cmake_dependent_option(CUPDLPX_BUILD_TESTS "Build the cuPDLPx test suite" OFF "CUPDLPX_BUILD_STATIC_LIB" OFF)
7678

79+
if(WIN32 AND CUPDLPX_BUILD_CLI)
80+
message(STATUS "Disabling CUPDLPX_BUILD_CLI on Windows (MSVC) due to getopt.h/libgen.h dependency.")
81+
set(CUPDLPX_BUILD_CLI OFF CACHE BOOL "Build the cuPDLPx command-line executable" FORCE)
82+
endif()
83+
7784
# -----------------------------------------------------------------------------
7885
# FIND DEPENDENCIES
7986
# -----------------------------------------------------------------------------
8087
find_package(CUDAToolkit REQUIRED)
8188
include(FetchContent)
8289

8390
# 1. ZLIB Configuration
84-
85-
set(BUILD_SHARED_LIBS OFF CACHE BOOL "" FORCE)
8691
find_package(ZLIB QUIET)
8792
if(NOT ZLIB_FOUND)
8893
FetchContent_Declare(
8994
zlib
9095
GIT_REPOSITORY https://github.com/madler/zlib.git
9196
GIT_TAG v1.3
9297
)
98+
FetchContent_MakeAvailable(zlib)
99+
endif()
93100

94-
FetchContent_GetProperties(zlib)
95-
if(NOT zlib_POPULATED)
96-
FetchContent_Populate(zlib)
97-
98-
file(WRITE "${zlib_SOURCE_DIR}/zlib.pc.cmakein" "")
99-
add_subdirectory(${zlib_SOURCE_DIR} ${zlib_BINARY_DIR} EXCLUDE_FROM_ALL)
100-
endif()
101-
101+
if(NOT TARGET ZLIB::ZLIB)
102102
if(TARGET zlibstatic)
103103
add_library(ZLIB::ZLIB ALIAS zlibstatic)
104-
target_include_directories(zlibstatic INTERFACE
105-
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
104+
target_include_directories(zlibstatic INTERFACE
105+
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
106+
$<BUILD_INTERFACE:${zlib_BINARY_DIR}>
107+
)
108+
elseif(TARGET zlib)
109+
add_library(ZLIB::ZLIB ALIAS zlib)
110+
target_include_directories(zlib INTERFACE
111+
$<BUILD_INTERFACE:${zlib_SOURCE_DIR}>
106112
$<BUILD_INTERFACE:${zlib_BINARY_DIR}>
107113
)
114+
else()
115+
message(FATAL_ERROR "ZLIB target not found. Expected ZLIB::ZLIB, zlibstatic, or zlib.")
108116
endif()
109117
endif()
110118

@@ -188,6 +196,10 @@ endif()
188196

189197
# 3. CLI Executable
190198
if(CUPDLPX_BUILD_CLI)
199+
if(NOT TARGET cupdlpx_core)
200+
message(FATAL_ERROR "CUPDLPX_BUILD_CLI=ON requires CUPDLPX_BUILD_STATIC_LIB=ON.")
201+
endif()
202+
191203
add_executable(cupdlpx_cli src/cli.c)
192204
target_include_directories(cupdlpx_cli PRIVATE include internal)
193205
target_link_libraries(cupdlpx_cli PRIVATE cupdlpx_core)
@@ -200,6 +212,10 @@ endif()
200212

201213
# 4. Tests
202214
if(CUPDLPX_BUILD_TESTS)
215+
if(NOT TARGET cupdlpx_core)
216+
message(FATAL_ERROR "CUPDLPX_BUILD_TESTS=ON requires CUPDLPX_BUILD_STATIC_LIB=ON.")
217+
endif()
218+
203219
enable_testing()
204220
file(GLOB TEST_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/test/*.c" "${CMAKE_CURRENT_SOURCE_DIR}/test/*.cu")
205221
foreach(TEST_SRC ${TEST_SOURCES})
@@ -217,6 +233,10 @@ endif()
217233

218234
# 5. Python Bindings
219235
if (CUPDLPX_BUILD_PYTHON)
236+
if(NOT TARGET cupdlpx_core)
237+
message(FATAL_ERROR "CUPDLPX_BUILD_PYTHON=ON requires CUPDLPX_BUILD_STATIC_LIB=ON.")
238+
endif()
239+
220240
find_package(pybind11 CONFIG REQUIRED)
221241
find_package(Python3 COMPONENTS Interpreter REQUIRED)
222242
add_subdirectory(python_bindings)
@@ -236,4 +256,4 @@ else()
236256
install(TARGETS cupdlpx_cli RUNTIME DESTINATION bin)
237257
endif()
238258
install(DIRECTORY include/ DESTINATION include/ FILES_MATCHING PATTERN "*.h")
239-
endif()
259+
endif()

0 commit comments

Comments
 (0)