-
Notifications
You must be signed in to change notification settings - Fork 320
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Overhaul CMake build rules for AMD and UMFPACK.
Avoid manually preprocessing the source files. Some compiler flags can easily be missed which can lead to compilation issues with the preprocessed sources (see #578). Instead, use object libraries to build the same source files with different flags. Potentially fixes the build issues described in #578.
- Loading branch information
Showing
2 changed files
with
177 additions
and
526 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,73 +1,30 @@ | ||
INCLUDE_DIRECTORIES(include) | ||
SET(UMFPACK_AMD_ORIG_SOURCES | ||
amd_aat.c | ||
amd_1.c | ||
amd_2.c | ||
amd_dump.c | ||
amd_postorder.c | ||
amd_post_tree.c | ||
amd_defaults.c | ||
amd_order.c | ||
amd_control.c | ||
amd_info.c | ||
amd_valid.c | ||
amd_preprocess.c | ||
set(UMFPACK_AMD_SOURCES | ||
amd_aat.c | ||
amd_1.c | ||
amd_2.c | ||
amd_dump.c | ||
amd_postorder.c | ||
amd_post_tree.c | ||
amd_defaults.c | ||
amd_order.c | ||
amd_control.c | ||
amd_info.c | ||
amd_valid.c | ||
amd_preprocess.c | ||
) | ||
SET(UMFPACK_AMD_CPP_SOURCES | ||
amd_i_aat.c | ||
amd_i_1.c | ||
amd_i_2.c | ||
amd_i_dump.c | ||
amd_i_postorder.c | ||
amd_i_post_tree.c | ||
amd_i_defaults.c | ||
amd_i_order.c | ||
amd_i_control.c | ||
amd_i_info.c | ||
amd_i_valid.c | ||
amd_i_preprocess.c | ||
amd_l_aat.c | ||
amd_l_1.c | ||
amd_l_2.c | ||
amd_l_dump.c | ||
amd_l_postorder.c | ||
amd_l_post_tree.c | ||
amd_l_defaults.c | ||
amd_l_order.c | ||
amd_l_control.c | ||
amd_l_info.c | ||
amd_l_valid.c | ||
amd_l_preprocess.c | ||
) | ||
|
||
SET(UMFMODIFIER_i_FLAGS -DDINT) | ||
SET(UMFMODIFIER_l_FLAGS -DDLONG) | ||
|
||
SET(UMFPACK_AMD_INCLUDES -I${CMAKE_CURRENT_SOURCE_DIR}/include -I${PROJECT_BINARY_DIR}) | ||
FOREACH(outfileName ${UMFPACK_AMD_CPP_SOURCES}) | ||
STRING(REGEX REPLACE "^amd_([a-z]*)_.*" "\\1" umfModifier "${outfileName}") | ||
STRING(REGEX REPLACE "^amd_${umfModifier}_([a-zA-Z0-9_]*)\\.c" "\\1" stem "${outfileName}") | ||
SET(infileName "amd_${stem}.c") | ||
|
||
SET(flags ${UMFMODIFIER_${umfModifier}_FLAGS} -DNBLAS -E) | ||
|
||
ADD_CUSTOM_COMMAND( | ||
OUTPUT ${outfileName} | ||
COMMAND ${CMAKE_C_COMPILER} | ||
ARGS ${UMFPACK_AMD_INCLUDES} ${flags} ${CMAKE_CURRENT_SOURCE_DIR}/${infileName} > ${outfileName} | ||
DEPENDS ${infileName} | ||
) | ||
|
||
ENDFOREACH(outfileName) | ||
ADD_CUSTOM_TARGET(umfpack_amd_srcs DEPENDS ${UMFPACK_AMD_ORIG_SOURCES}) | ||
|
||
ADD_LIBRARY(amd STATIC amd_internal.h ${UMFPACK_AMD_CPP_SOURCES}) | ||
ADD_LIBRARY(amdf77 STATIC amd.f amdbar.f) | ||
add_library(amd_i OBJECT ${UMFPACK_AMD_SOURCES}) | ||
target_include_directories(amd_i PRIVATE include) | ||
target_compile_definitions(amd_i PRIVATE NBLAS DINT) | ||
|
||
INSTALL(TARGETS amd amdf77 DESTINATION ${ELMER_INSTALL_LIB_DIR}) | ||
add_library(amd_l OBJECT ${UMFPACK_AMD_SOURCES}) | ||
target_include_directories(amd_l PRIVATE include) | ||
target_compile_definitions(amd_l PRIVATE NBLAS DLONG) | ||
|
||
IF(WIN32) | ||
INSTALL(TARGETS amd amdf77 ARCHIVE DESTINATION ${ELMER_INSTALL_LIB_DIR} | ||
RUNTIME DESTINATION ${ELMER_INSTALL_LIB_DIR}) | ||
ENDIF() | ||
add_library(amd STATIC $<TARGET_OBJECTS:amd_i> $<TARGET_OBJECTS:amd_l>) | ||
add_library(amdf77 STATIC amd.f amdbar.f) | ||
|
||
install(TARGETS amd amdf77 | ||
ARCHIVE DESTINATION ${ELMER_INSTALL_LIB_DIR} | ||
RUNTIME DESTINATION ${ELMER_INSTALL_BIN_DIR} | ||
LIBRARY DESTINATION ${ELMER_INSTALL_LIB_DIR}) |
Oops, something went wrong.