Skip to content

Commit 2bae5ce

Browse files
committed
Accept the unprefixed import library name on Windows
The example builds searched only for _cspimpl, but CMake applies the leading underscore to the module and not to its import library, so the wheel ships csp/lib/_cspimpl.pyd alongside csp/lib/cspimpl.lib. Every Windows example failed to configure with CSP_LIBRARY-NOTFOUND. Search both names, preferring the underscored one if a build ever produces it. Confirmed against the wheel from this branch: cspimpl.lib is present and exports both the C API symbols and the C++ symbols the older examples link. Signed-off-by: Tim Paine <3105306+timkpaine@users.noreply.github.com>
1 parent 9d76206 commit 2bae5ce

4 files changed

Lines changed: 12 additions & 8 deletions

File tree

examples/05_cpp/1_cpp_node/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ execute_process(
1313
COMMAND "${Python_EXECUTABLE}" -c "import csp; print(csp.get_lib_path(), end='')"
1414
OUTPUT_VARIABLE CSP_LIB_DIR)
1515

16-
# Windows links the import library; elsewhere the module itself is linked
16+
# Windows links the import library; elsewhere the module itself is linked. CMake applies the
17+
# leading underscore to the module but not to its import library, so accept either name.
1718
if(WIN32)
18-
find_library(CSP_LIBRARY NAMES _cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
19+
find_library(CSP_LIBRARY NAMES _cspimpl cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
1920
else()
2021
find_library(CSP_LIBRARY NAMES _cspimpl.so PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
2122
endif()

examples/05_cpp/2_cpp_node_with_struct/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ execute_process(
1313
COMMAND "${Python_EXECUTABLE}" -c "import csp; print(csp.get_lib_path(), end='')"
1414
OUTPUT_VARIABLE CSP_LIB_DIR)
1515

16-
# Windows links the import library; elsewhere the module itself is linked
16+
# Windows links the import library; elsewhere the module itself is linked. CMake applies the
17+
# leading underscore to the module but not to its import library, so accept either name.
1718
if(WIN32)
18-
find_library(CSP_LIBRARY NAMES _cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
19+
find_library(CSP_LIBRARY NAMES _cspimpl cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
1920
else()
2021
find_library(CSP_LIBRARY NAMES _cspimpl.so PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
2122
endif()

examples/05_cpp/3_cpp_adapter/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ execute_process(
1313
COMMAND "${Python_EXECUTABLE}" -c "import csp; print(csp.get_lib_path(), end='')"
1414
OUTPUT_VARIABLE CSP_LIB_DIR)
1515

16-
# Windows links the import library; elsewhere the module itself is linked
16+
# Windows links the import library; elsewhere the module itself is linked. CMake applies the
17+
# leading underscore to the module but not to its import library, so accept either name.
1718
if(WIN32)
18-
find_library(CSP_LIBRARY NAMES _cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
19+
find_library(CSP_LIBRARY NAMES _cspimpl cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
1920
else()
2021
find_library(CSP_LIBRARY NAMES _cspimpl.so PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
2122
endif()

examples/05_cpp/4_c_api_adapter/CMakeLists.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ execute_process(
1313
COMMAND "${Python_EXECUTABLE}" -c "import csp; print(csp.get_lib_path(), end='')"
1414
OUTPUT_VARIABLE CSP_LIB_DIR)
1515

16-
# Windows links the import library; elsewhere the module itself is linked
16+
# Windows links the import library; elsewhere the module itself is linked. CMake applies the
17+
# leading underscore to the module but not to its import library, so accept either name.
1718
if(WIN32)
18-
find_library(CSP_LIBRARY NAMES _cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
19+
find_library(CSP_LIBRARY NAMES _cspimpl cspimpl PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
1920
else()
2021
find_library(CSP_LIBRARY NAMES _cspimpl.so PATHS "${CSP_LIB_DIR}" NO_DEFAULT_PATH)
2122
endif()

0 commit comments

Comments
 (0)