Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
allows to compile umfpack in 3rdParty and use it in cpp-runtime
only the LGPL version in 3rdParty is used git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@22028 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
- Loading branch information
Michael Kloeppel
committed
Aug 27, 2014
1 parent
40d25e0
commit 02d1168
Showing
6 changed files
with
78 additions
and
128 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
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
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
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
152 changes: 37 additions & 115 deletions
152
SimulationRuntime/cpp/Solver/UmfPack/SuiteSparseConfig.cmake
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,125 +1,47 @@ | ||
set(SuiteSparse_found true) | ||
find_file(UMFPACK_H umfpack.h) | ||
message(STATUS "Searching for UmfPack") | ||
find_file(UMFPACK_H umfpack.h HINTS "${CMAKE_SOURCE_DIR}/../../build/include/omc/c/suitesparse") | ||
if(UMFPACK_H) | ||
get_filename_component(SUITESPARSE_INCLUDE_DIRS "${UMFPACK_H}" PATH) | ||
get_filename_component(UMFPACK_INCLUDE_DIRS "${UMFPACK_H}" PATH) | ||
message(STATUS "${UMFPACK_H}") | ||
else() | ||
message(STATUS "umfpack.h not found") | ||
set(SuiteSparse_found false) | ||
endif() | ||
find_library(UMFPACK_LIB umfpack | ||
HINTS ENV LIBRARY_PATH | ||
HINTS "${CMAKE_SOURCE_DIR}/../../build/lib/omc" | ||
NO_DEFAULT_PATH | ||
DOC "The UMFPACK library") | ||
if(UMFPACK_LIB) | ||
list(APPEND SUITESPARSE_LIBRARIES ${UMFPACK_LIB}) | ||
else() | ||
message("Could not find the UMFPACK library") | ||
set(SuiteSparse_found false) | ||
endif() | ||
find_package(BLAS) | ||
if(BLAS_FOUND) | ||
if(UMFPACK_LIB) | ||
list(APPEND SUITESPARSE_LIBRARIES ${UMFPACK_LIB}) | ||
else() | ||
message(STATUS "Could not find the UMFPACK library") | ||
set(SuiteSparse_found false) | ||
endif() | ||
|
||
find_package(BLAS) | ||
if(BLAS_FOUND) | ||
list(APPEND SUITESPARSE_LIBRARIES ${BLAS_LIBRARIES}) | ||
else() | ||
else() | ||
message(STATUS "Could not find the BLAS library. Please set the variable BLAS_LIBRARY to the blas library with full path") | ||
endif() | ||
|
||
|
||
find_library(AMD_LIB amd | ||
HINTS ENV LIBRARY_PATH | ||
DOC "The AMD library") | ||
if(AMD_LIB) | ||
list(APPEND SUITESPARSE_LIBRARIES ${AMD_LIB}) | ||
else() | ||
message("Could not find the AMD library.") | ||
set(SuiteSparse_found false) | ||
endif() | ||
#check for if we need cholmod | ||
set(_CHOLMOD_TEST_DIR ${CMAKE_BINARY_DIR}/CMakeFiles/cholmodTest/) | ||
file(WRITE ${_CHOLMOD_TEST_DIR}/CMakeLists.txt "project(cholmodTest) | ||
cmake_minimum_required(VERSION 2.8) | ||
include_directories(${SUITESPARSE_INCLUDE_DIRS}) | ||
add_executable(cholmodTest cholmodTest.cpp) | ||
target_link_libraries(cholmodTest ${SUITESPARSE_LIBRARIES})") | ||
file(WRITE ${_CHOLMOD_TEST_DIR}/cholmodTest.cpp "#include <stdio.h> | ||
#include \"umfpack.h\" | ||
int n = 5 ; | ||
int Ap [ ] = {0, 2, 5, 9, 10, 12} ; | ||
int Ai [ ] = { 0, 1, 0, 2, 4, 1, 2, 3, 4, 2, 1, 4} ; | ||
double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ; | ||
double b [ ] = {8., 45., -3., 3., 19.} ; | ||
double x [5] ; | ||
int main (void) | ||
{ | ||
double *null = (double *) NULL ; | ||
int i ; | ||
void *Symbolic, *Numeric ; | ||
double stats [2]; | ||
umfpack_tic (stats); | ||
(void) umfpack_di_symbolic (n, n, Ap, Ai, Ax, &Symbolic, null, null) ; | ||
(void) umfpack_di_numeric (Ap, Ai, Ax, Symbolic, &Numeric, null, null) ; | ||
umfpack_di_free_symbolic (&Symbolic) ; | ||
(void) umfpack_di_solve (UMFPACK_A, Ap, Ai, Ax, x, b, Numeric, null, null) ; | ||
umfpack_di_free_numeric (&Numeric) ; | ||
umfpack_toc (stats); | ||
return (0) ; | ||
}") | ||
# "#include <umfpack.h> | ||
# int main(int , char* argv[]) { double c[UMFPACK_CONTROL]; umfpack_dl_defaults(c); return 0;}") | ||
try_compile(CHOLMOD_TEST ${_CHOLMOD_TEST_DIR}/build ${_CHOLMOD_TEST_DIR} cholmodTest | ||
OUTPUT_VARIABLE CHOLMOD_OUT) | ||
if(NOT CHOLMOD_TEST) | ||
file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "cholmodTest-output: \n ${CHOLMOD_OUT}") | ||
find_library(CHOLMOD_LIB cholmod) | ||
find_library(COLAMD_LIB colamd) | ||
endif() | ||
|
||
if(CHOLMOD_LIB) | ||
list(APPEND SUITESPARSE_LIBRARIES ${CHOLMOD_LIB}) | ||
else() | ||
message("your umfpack seems to need cholmod, but cmake could not find it") | ||
set(SuiteSparse_found false) | ||
endif() | ||
if(COLAMD_LIB) | ||
list(APPEND SUITESPARSE_LIBRARIES ${COLAMD_LIB}) | ||
else() | ||
message("your umfpack seems to need colamd, but cmake could not find it") | ||
set(SuiteSparse_found false) | ||
endif() | ||
|
||
#test with cholmod and colamd.. | ||
file(WRITE ${_CHOLMOD_TEST_DIR}/CMakeLists.txt "project(cholmodTest) | ||
cmake_minimum_required(VERSION 2.8) | ||
include_directories(${AMDIS_INCLUDE_DIRS}) | ||
add_executable(cholmodTest cholmodTest.cpp) | ||
target_link_libraries(cholmodTest ${AMDIS_LIBRARIES})") | ||
try_compile(CHOLMOD_TEST2 ${_CHOLMOD_TEST_DIR}/build ${_CHOLMOD_TEST_DIR} cholmodTest | ||
OUTPUT_VARIABLE CHOLMOD_OUT) | ||
if(NOT CHOLMOD_TEST2) | ||
file(APPEND ${CMAKE_BINARY_DIR}/CMakeFiles/CMakeError.log "cholmodTest2-output: \n ${CHOLMOD_OUT}") | ||
find_library(SUITESPARSECONFIG_LIB suitesparseconfig) | ||
if(SUITESPARSECONFIG_LIB) | ||
list(APPEND SUITESPARSE_LIBRARIES ${SUITESPARSECONFIG_LIB}) | ||
else() | ||
message(STATUS "your umfpack seems to need suitesparseconfig, but cmake could not find it") | ||
set(SuiteSparse_found false) | ||
endif() | ||
endif() | ||
endif() | ||
find_library(AMD_LIB amd | ||
HINTS "${CMAKE_SOURCE_DIR}/../../build/lib/omc" | ||
NO_DEFAULT_PATH | ||
DOC "The AMD library") | ||
if(AMD_LIB) | ||
list(APPEND SUITESPARSE_LIBRARIES ${AMD_LIB}) | ||
else() | ||
message("Could not find the AMD library.") | ||
set(SuiteSparse_found false) | ||
endif() | ||
|
||
find_file(UFCONFIG_H UFconfig.h HINTS "${CMAKE_SOURCE_DIR}/../../build/include/omc/c/suitesparse") | ||
if(UFCONFIG_H) | ||
get_filename_component(SUITESPARSE_INCLUDE_DIRS "${UFCONFIG_H}" PATH) | ||
else() | ||
message(STATUS "UFconfig.h not found") | ||
set(SuiteSparse_found false) | ||
endif() |
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