Skip to content

Commit

Permalink
Fix issues with paths containing blanks for sundials (#2361)
Browse files Browse the repository at this point in the history
...
  • Loading branch information
dweindl authored Mar 6, 2024
1 parent 19f7baf commit dcc81d1
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 12 deletions.
6 changes: 3 additions & 3 deletions ThirdParty/sundials/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -27,9 +27,9 @@ project(SUNDIALS C)

# Specify the location of additional CMAKE modules
set(CMAKE_MODULE_PATH
${PROJECT_SOURCE_DIR}/cmake
${PROJECT_SOURCE_DIR}/cmake/macros
${PROJECT_SOURCE_DIR}/cmake/tpl
"${PROJECT_SOURCE_DIR}/cmake"
"${PROJECT_SOURCE_DIR}/cmake/macros"
"${PROJECT_SOURCE_DIR}/cmake/tpl"
)

# MACRO definitions
Expand Down
2 changes: 1 addition & 1 deletion ThirdParty/sundials/cmake/tpl/FindKLU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ if (NOT SUITESPARSECONFIG_LIBRARY)
mark_as_advanced(SUITESPARSECONFIG_LIBRARY)
endif ()

set(KLU_LIBRARIES ${KLU_LIBRARY} ${AMD_LIBRARY} ${COLAMD_LIBRARY} ${BTF_LIBRARY} ${SUITESPARSECONFIG_LIBRARY})
set(KLU_LIBRARIES "${KLU_LIBRARY}" "${AMD_LIBRARY}" "${COLAMD_LIBRARY}" "${BTF_LIBRARY}" "${SUITESPARSECONFIG_LIBRARY}")

# set package variables including KLU_FOUND
include(FindPackageHandleStandardArgs)
Expand Down
17 changes: 9 additions & 8 deletions ThirdParty/sundials/cmake/tpl/SundialsKLU.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,8 @@ find_package(KLU REQUIRED)

message(STATUS "KLU_LIBRARIES: ${KLU_LIBRARIES}")
message(STATUS "KLU_INCLUDE_DIR: ${KLU_INCLUDE_DIR}")

list(JOIN KLU_LIBRARIES "\" \"" KLU_LIBRARIES_TMP)
set(KLU_LIBRARIES_TMP \"${KLU_LIBRARIES_TMP}\")
# -----------------------------------------------------------------------------
# Section 4: Test the TPL
# -----------------------------------------------------------------------------
Expand All @@ -58,11 +59,11 @@ if(KLU_FOUND AND (NOT KLU_WORKS))
# Do any checks which don't require compilation first.

# Create the KLU_TEST directory
set(KLU_TEST_DIR ${PROJECT_BINARY_DIR}/KLU_TEST)
set(KLU_TEST_DIR "${PROJECT_BINARY_DIR}/KLU_TEST")
file(MAKE_DIRECTORY ${KLU_TEST_DIR})

# Create a CMakeLists.txt file
file(WRITE ${KLU_TEST_DIR}/CMakeLists.txt
file(WRITE "${KLU_TEST_DIR}/CMakeLists.txt"
"CMAKE_MINIMUM_REQUIRED(VERSION 3.1.3)\n"
"PROJECT(ltest C)\n"
"SET(CMAKE_VERBOSE_MAKEFILE ON)\n"
Expand All @@ -72,12 +73,12 @@ if(KLU_FOUND AND (NOT KLU_WORKS))
"SET(CMAKE_C_FLAGS_DEBUG \"${CMAKE_C_FLAGS_DEBUG}\")\n"
"SET(CMAKE_C_FLAGS_RELWITHDEBUGINFO \"${CMAKE_C_FLAGS_RELWITHDEBUGINFO}\")\n"
"SET(CMAKE_C_FLAGS_MINSIZE \"${CMAKE_C_FLAGS_MINSIZE}\")\n"
"INCLUDE_DIRECTORIES(${KLU_INCLUDE_DIR})\n"
"INCLUDE_DIRECTORIES(\"${KLU_INCLUDE_DIR}\")\n"
"ADD_EXECUTABLE(ltest ltest.c)\n"
"TARGET_LINK_LIBRARIES(ltest ${KLU_LIBRARIES})\n")
"TARGET_LINK_LIBRARIES(ltest ${KLU_LIBRARIES_TMP})\n")

# Create a C source file which calls a KLU function
file(WRITE ${KLU_TEST_DIR}/ltest.c
file(WRITE "${KLU_TEST_DIR}/ltest.c"
"\#include \"klu.h\"\n"
"int main(){\n"
"klu_common Common;\n"
Expand All @@ -87,10 +88,10 @@ if(KLU_FOUND AND (NOT KLU_WORKS))

# To ensure we do not use stuff from the previous attempts,
# we must remove the CMakeFiles directory.
file(REMOVE_RECURSE ${KLU_TEST_DIR}/CMakeFiles)
file(REMOVE_RECURSE "${KLU_TEST_DIR}/CMakeFiles")

# Attempt to build and link the "ltest" executable
try_compile(COMPILE_OK ${KLU_TEST_DIR} ${KLU_TEST_DIR} ltest
try_compile(COMPILE_OK "${KLU_TEST_DIR}" "${KLU_TEST_DIR}" ltest
OUTPUT_VARIABLE COMPILE_OUTPUT)

# Process test result
Expand Down

0 comments on commit dcc81d1

Please sign in to comment.