Commit 75089abd authored by Max Lyon's avatar Max Lyon

Merge branch 'CMakeTarget'

parents a9cd1f34 cbaed7b7
cmake_minimum_required (VERSION 2.6)
cmake_minimum_required (VERSION 3.9)
if (WIN32)
cmake_minimum_required (VERSION 3.13)
endif()
#Only set project name if CoMISo is built as stand-alone library
if("${PROJECT_NAME}" STREQUAL "")
......@@ -59,14 +62,13 @@ else()
endif ()
find_package (GMM)
find_package (GMM REQUIRED)
if (GMM_FOUND)
set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${GMM_INCLUDE_DIR} )
list (APPEND NEED_LAPACK "GMM")
else()
set (COMISO_GMM_CONFIG_FILE_SETTINGS "#define COMISO_GMM_AVAILABLE 0" )
message (FATAL_ERROR "GMM not found!")
endif ()
set(TMP_CMAKE_FIND_LIBRARY_PREFIXES "${CMAKE_FIND_LIBRARY_PREFIXES}")
......@@ -104,15 +106,18 @@ if (SUITESPARSE_FOUND )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${SUITESPARSE_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_DIRECTORIES ${SUITESPARSE_LIBRARY_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${SUITESPARSE_LIBRARIES} )
# special handling, since spqr is incorrect in several distributions
if(SUITESPARSE_SPQR_VALID)
set (COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_SPQR_AVAILABLE 1" )
else()
message (STATUS "SUITESPARSE SPQR seems to be invalid!")
set (COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_SPQR_AVAILABLE 0" )
endif()
else ()
message (STATUS "SUITESPARSE not found!")
set (COMISO_SUITESPARSE_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_AVAILABLE 0" )
endif ()
# special handling, since spqr is incorrect in several distributions
if(SUITESPARSE_SPQR_VALID)
set (COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_SPQR_AVAILABLE 1" )
else()
message (STATUS "SUITESPARSE SPQR seems to be invalid!")
set (COMISO_SUITESPARSE_SPQR_CONFIG_FILE_SETTINGS "#define COMISO_SUITESPARSE_SPQR_AVAILABLE 0" )
endif()
......@@ -188,9 +193,9 @@ endif ()
find_package (IPOPT)
if (IPOPT_FOUND)
set (COMISO_IPOPT_CONFIG_FILE_SETTINGS "#define COMISO_IPOPT_AVAILABLE 1" )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${IPOPT_INCLUDE_DIR} )
list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIR} )
list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARY} )
list( APPEND COMISO_INCLUDE_DIRECTORIES ${IPOPT_INCLUDE_DIRS} )
list( APPEND COMISO_LINK_DIRECTORIES ${IPOPT_LIBRARY_DIRS} )
list( APPEND COMISO_LINK_LIBRARIES ${IPOPT_LIBRARIES} )
if ( IPOPT_HSL_LIBRARY_DIR )
set (COMISO_HSL_CONFIG_FILE_SETTINGS "#define COMISO_HSL_AVAILABLE 1" )
else ()
......@@ -344,35 +349,6 @@ if (NEED_LAPACK AND NOT SUITESPARSE_FOUND)
endif(NEED_LAPACK AND NOT SUITESPARSE_FOUND)
set(CMAKE_FIND_LIBRARY_PREFIXES "${TMP_CMAKE_FIND_LIBRARY_PREFIXES}")
include_directories (
..
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../
${COMISO_INCLUDE_DIRECTORIES}
)
# generate dllexport macros on windows
if (WIN32)
add_definitions(-DCOMISODLL)
add_definitions(-DBASEDLL)
add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
# ignore "... needs to have dll-interface to be used by clients"
add_definitions(/wd4251)
endif ()
link_directories (
${COMISO_LINK_DIRECTORIES}
)
# enable debug stuff
set (COMISO_ENABLE_DEBUG_OUTPUT TRUE CACHE BOOL "Enable CoMISo Debug Output")
if (COMISO_ENABLE_DEBUG_OUTPUT)
add_definitions(-DDEB_ON)
endif ()
# source code directories
set (directories
.
......@@ -388,17 +364,6 @@ set (directories
QtWidgets
)
if (WIN32)
add_definitions(
-D_USE_MATH_DEFINES -DNOMINMAX
)
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]")
# disable unused parameter warning
add_definitions(-Wno-unused-parameter -Wno-deprecated-register)
endif()
# collect all header,source and ui files
acg_append_files (headers "*.hh" ${directories})
acg_append_files (sources "*.cc" ${directories})
......@@ -407,7 +372,6 @@ if( QT5_FOUND )
acg_append_files (ui "*.ui" ${directories})
endif()
macro (of_list_filter _list)
if (WIN32)
foreach (_element ${${_list}})
......@@ -421,22 +385,74 @@ endmacro ()
of_list_filter ( headers )
of_list_filter ( sources )
# remove template cc files from source file list
acg_drop_templates (sources)
if ( QT5_FOUND )
# Enable automoc
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
list (APPEND COMISO_LINK_LIBRARIES ${QT_LIBRARIES})
endif()
# TODO: remove this line when we can assume people have a cmake 3.13.
# Then link directories is set as target property below.
link_directories(${COMISO_LINK_DIRECTORIES})
acg_add_library (CoMISo SHARED ${ui} ${sources} ${headers} )
add_library(CoMISo::CoMISo ALIAS CoMISo)
target_include_directories (CoMISo PUBLIC
$<BUILD_INTERFACE:
${CMAKE_CURRENT_SOURCE_DIR}
${CMAKE_CURRENT_SOURCE_DIR}/../
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/../>
$<INSTALL_INTERFACE:include>
${COMISO_INCLUDE_DIRECTORIES}
)
get_target_property(INC_DIRS CoMISo INCLUDE_DIRECTORIES)
message("Target CoMISo include dirs: ${INC_DIRS}")
message("COMISO_INCLUDE_DIRECTORIES: ${COMISO_INCLUDE_DIRECTORIES}")
message("COMISO_LINK_DIRECTORIES: ${COMISO_LINK_DIRECTORIES}")
if (COMISO_LINK_DIRECTORIES)
set_target_properties(CoMISo PROPERTIES LINK_DIRECTORIES "${COMISO_LINK_DIRECTORIES}")
endif()
if (WIN32)
#TODO: do this also for non windows platforms as soon as we can require cmake 3.13
target_link_directories(CoMISo PUBLIC ${COMISO_LINK_DIRECTORIES})
endif()
# generate dllexport macros on windows
if (WIN32)
add_definitions(-DCOMISODLL)
add_definitions(-DBASEDLL)
add_definitions(-D_SCL_SECURE_NO_DEPRECATE)
# ignore "... needs to have dll-interface to be used by clients"
#add_definitions(/wd4251)
target_compile_definitions(CoMISo PRIVATE /wd4251)
endif ()
# enable debug stuff
set (COMISO_ENABLE_DEBUG_OUTPUT TRUE CACHE BOOL "Enable CoMISo Debug Output")
if (COMISO_ENABLE_DEBUG_OUTPUT)
#add_definitions(-DDEB_ON)
target_compile_definitions(CoMISo PRIVATE -DDEB_ON)
endif ()
if (WIN32)
#add_definitions(-D_USE_MATH_DEFINES -DNOMINMAX)
target_compile_definitions(CoMISo PRIVATE -D_USE_MATH_DEFINES -DNOMINMAX)
endif ()
if (CMAKE_CXX_COMPILER_ID MATCHES "[cC][lL][aA][nN][gG]")
# disable unused parameter warning
#add_definitions(-Wno-unused-parameter -Wno-deprecated-register)
target_compile_options(CoMISo PRIVATE -Wno-unused-parameter -Wno-deprecated-register)
endif()
if ( QT5_FOUND )
if ( NOT WIN32 )
......@@ -562,10 +578,10 @@ endif (COMISO_BUILD_EXAMPLES )
if(${PROJECT_NAME} MATCHES "CoMISo")
# Install library
install (TARGETS CoMISo
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
install (TARGETS CoMISo EXPORT CoMISoTargets
RUNTIME DESTINATION lib
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
# Install Header Files
install(DIRECTORY .
......@@ -585,6 +601,16 @@ if(${PROJECT_NAME} MATCHES "CoMISo")
# Install Config File
install( FILES ${CMAKE_BINARY_DIR}/CoMISo/Config/config.hh
DESTINATION include/CoMISo/Config )
install(EXPORT CoMISoTargets
FILE CoMISoTargets.cmake
NAMESPACE CoMISo::
DESTINATION cmake)
install(FILES "${CMAKE_CURRENT_LIST_DIR}/cmake/CoMISoConfig.cmake"
DESTINATION cmake
)
endif()
include(CMakeFindDependencyMacro)
# Add the targets file
include("${CMAKE_CURRENT_LIST_DIR}/CoMISoTargets.cmake")
......@@ -48,8 +48,8 @@ if (WIN32)
"${VS_SEARCH_PATH}Ipopt-3.12.9/include/coin"
"${VS_SEARCH_PATH}Ipopt-3.12.4/Ipopt/MSVisualStudio/v8-ifort/installed/include/coin"
"${VS_SEARCH_PATH}Ipopt-3.11.9/Ipopt/MSVisualStudio/v8-ifort/installed/include/coin"
"C:\\libs\\Ipopt-3.8.2\\include\\coin"
${IPOPT_DIR}/include
"C:\\libs\\Ipopt-3.8.2\\include\\coin"
${IPOPT_DIR}/include
)
IF(IPOPT_INCLUDE_DIR)
......@@ -70,34 +70,40 @@ if (WIN32)
set ( IPOPT_LIBRARY "optimized;${IPOPT_LIBRARY_RELEASE};debug;${IPOPT_LIBRARY_DEBUG}" CACHE STRING "IPOPT Libraries" )
GET_FILENAME_COMPONENT(IPOPT_LIBRARY_DIR ${IPOPT_LIBRARY_RELEASE} PATH )
MARK_AS_ADVANCED(IPOPT_LIBRARY_DIR)
GET_FILENAME_COMPONENT(IPOPT_LIBRARY_DIR ${IPOPT_LIBRARY_RELEASE} PATH )
MARK_AS_ADVANCED(IPOPT_LIBRARY_DIR)
SET(IPOPT_FOUND TRUE)
SET(IPOPT_INCLUDE_DIR ${IPOPT_INCLUDE_DIR})
SET(IPOPT_INCLUDE_DIRS ${IPOPT_INCLUDE_DIR})
SET(IPOPT_LIBRARY_DIRS ${IPOPT_LIBRARY_DIR})
set(IPOPT_LIBRARIES "${IPOPT_LIBRARY}" )
# Todo, set right version depending on build type (debug/release)
#GET_FILENAME_COMPONENT( IPOPT_LIBRARY_DIR ${GLEW_LIBRARY} PATH )
#GET_FILENAME_COMPONENT( IPOPT_LIBRARY_DIRS ${GLEW_LIBRARY} PATH )
ELSE(IPOPT_INCLUDE_DIR)
SET(IPOPT_FOUND FALSE)
SET(IPOPT_INCLUDE_DIR ${IPOPT_INCLUDE_DIR})
SET(IPOPT_INCLUDE_DIRS ${IPOPT_INCLUDE_DIR})
ENDIF(IPOPT_INCLUDE_DIR)
ELSE( WIN32 )
find_path(IPOPT_INCLUDE_DIR NAMES IpNLP.hpp
HINTS "$ENV{IPOPT_HOME}/include/coin"
PATHS "$ENV{IPOPT_HOME}/include/coin"
"/usr/include/coin"
"~/sw/Ipopt-3.12.4-installed/include/coin"
)
find_library( IPOPT_LIBRARY
ipopt
HINTS "$ENV{IPOPT_HOME}/lib"
"/usr/lib" )
PATHS
"/usr/lib"
"~/sw/Ipopt-3.12.4-installed/lib"
)
#wrong config under Debian workaround
add_definitions( -DHAVE_CSTDDEF )
# set optional path to HSL Solver for dynamic usage
find_path(IPOPT_HSL_LIBRARY_DIR
NAMES libhsl.so
......@@ -106,25 +112,26 @@ ELSE( WIN32 )
"$ENV{HOME}/opt/HSL/lib"
)
# find HSL library for fixed linking of solvers
# find HSL library for fixed linking of solvers
find_library( IPOPT_HSL_LIBRARY
NAMES hsl coinhsl
coinhsl hsl
HINTS "$ENV{IPOPT_HSL_LIBRARY_PATH}"
"$ENV{IPOPT_HOME}/lib"
"/usr/lib" )
PATHS "/usr/lib" )
set(IPOPT_LIBRARY_DIRS "${IPOPT_LIBRARY_DIR}" )
set(IPOPT_INCLUDE_DIRS "${IPOPT_INCLUDE_DIR}" )
set(IPOPT_LIBRARIES "${IPOPT_LIBRARY}" )
IF( IPOPT_HSL_LIBRARY_DIR)
IF( NOT IPOPT_FIND_QUIETLY )
message ( "IPOPT_HSL_LIBRARY_DIR found at ${IPOPT_HSL_LIBRARY_DIR} ")
ENDIF()
set(IPOPT_LIBRARY_DIR ${IPOPT_HSL_LIBRARY_DIR})
LIST( APPEND IPOPT_LIBRARY_DIRS "${IPOPT_HSL_LIBRARY_DIR}")
ENDIF(IPOPT_HSL_LIBRARY_DIR)
set(IPOPT_INCLUDE_DIRS "${IPOPT_INCLUDE_DIR}" )
set(IPOPT_LIBRARIES "${IPOPT_LIBRARY}" )
IF(IPOPT_HSL_LIBRARY)
LIST( APPEND IPOPT_LIBRARIES "${IPOPT_HSL_LIBRARY}")
......
......@@ -36,30 +36,31 @@ endif()
find_path(METIS_INCLUDE_DIR NAMES metis.h
PATHS "$ENV{IPOPT_HOME}/ThirdParty/Metis/metis-4.0/Lib/"
"/usr/include/"
HINTS "$ENV{IPOPT_HOME}/include/coin/ThirdParty"
"$ENV{IPOPT_HOME}/ThirdParty/Metis/metis-4.0/Lib/"
PATHS "/usr/include/"
"/usr/include/metis"
"/opt/local/include"
"/opt/local/include/metis"
"${VS_SEARCH_PATH}Ipopt-3.12.9/include/metis"
"${VS_SEARCH_PATH}Ipopt-3.12.9/include/metis"
"${VS_SEARCH_PATH}Ipopt-3.12.4/Ipopt/MSVisualStudio/v8-ifort/installed/include/metis"
)
find_library( METIS_LIBRARY_RELEASE
metis coinmetis
PATHS "$ENV{IPOPT_HOME}/lib/"
"/usr/lib"
coinmetis metis
HINTS "$ENV{IPOPT_HOME}/lib/"
PATHS "/usr/lib"
"/opt/local/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.4/Ipopt/MSVisualStudio/v8-ifort/installed/lib"
)
find_library( METIS_LIBRARY_DEBUG
metisd coinmetisd
PATHS "$ENV{IPOPT_HOME}/lib/"
"/usr/lib"
coinmetisd metisd
HINTS "$ENV{IPOPT_HOME}/lib/"
PATHS "/usr/lib"
"/opt/local/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.4/Ipopt/MSVisualStudio/v8-ifort/installed/lib"
)
......
......@@ -35,27 +35,28 @@ elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 15.*" )
endif()
find_path(MUMPS_INCLUDE_DIR NAMES dmumps_c.h
PATHS "$ENV{IPOPT_HOME}/ThirdParty/Mumps/MUMPS/include/"
"/usr/include/"
"${VS_SEARCH_PATH}Ipopt-3.12.9/include/mumps"
HINTS "$ENV{IPOPT_HOME}/include/coin/ThirdParty/"
"$ENV{IPOPT_HOME}/ThirdParty/Mumps/MUMPS/include/"
PATHS "/usr/include/"
"${VS_SEARCH_PATH}Ipopt-3.12.9/include/mumps"
"${VS_SEARCH_PATH}Ipopt-3.12.4/Ipopt/MSVisualStudio/v8-ifort/installed/include/mumps"
)
find_library( MUMPS_LIBRARY_DEBUG
dmumpsd coinmumpsd coinmumpscd
PATHS "$ENV{IPOPT_HOME}/lib/"
"/usr/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
HINTS "$ENV{IPOPT_HOME}/lib/"
PATHS "/usr/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.4/Ipopt/MSVisualStudio/v8-ifort/installed/lib"
)
find_library( MUMPS_LIBRARY_RELEASE
dmumps coinmumps coinmumpsc
PATHS "$ENV{IPOPT_HOME}/lib/"
"/usr/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
coinmumps dmumps coinmumpsc
HINTS "$ENV{IPOPT_HOME}/lib/"
PATHS "/usr/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.9/lib"
"${VS_SEARCH_PATH}Ipopt-3.12.4/Ipopt/MSVisualStudio/v8-ifort/installed/lib"
)
)
include(SelectLibraryConfigurations)
select_library_configurations( MUMPS )
......
......@@ -10,172 +10,201 @@
# SUITESPARSE_LIBRARY_DIRS - all Library directories containing suitesparse libs
# SUITESPARSE_SPQR_VALID - automatic identification whether or not spqr package is installed correctly
IF (SUITESPARSE_INCLUDE_DIRS)
if (SUITESPARSE_INCLUDE_DIRS)
# Already in cache, be silent
SET(SUITESPARSE_FIND_QUIETLY TRUE)
ENDIF (SUITESPARSE_INCLUDE_DIRS)
endif (SUITESPARSE_INCLUDE_DIRS)
if( WIN32 )
# Find cholmod part of the suitesparse library collection
# Check if the base path is set
if ( NOT CMAKE_WINDOWS_LIBS_DIR )
# This is the base directory for windows library search used in the finders we shipp.
set(CMAKE_WINDOWS_LIBS_DIR "c:/libs" CACHE STRING "Default Library search dir on windows." )
endif()
if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x32/")
endif()
FIND_PATH( CHOLMOD_INCLUDE_DIR cholmod.h
PATHS "C:\\libs\\win32\\SuiteSparse\\Include"
"${VS_SEARCH_PATH}"
PATH_SUFFIXES suitesparse-4.2.1/include/suitesparse
suitesparse-metis-for-windows-1.2.2-install/include/suitesparse
)
# Add cholmod include directory to collection include directories
IF ( CHOLMOD_INCLUDE_DIR )
list ( APPEND SUITESPARSE_INCLUDE_DIRS ${CHOLMOD_INCLUDE_DIR} )
ENDIF( CHOLMOD_INCLUDE_DIR )
# find path suitesparse library
FIND_PATH( SUITESPARSE_LIBRARY_DIRS
NAMES amd.lib libamd.lib
PATHS "C:\\libs\\win32\\SuiteSparse\\libs"
"${VS_SEARCH_PATH}"
PATH_SUFFIXES suitesparse-4.2.1/lib64
suitesparse-metis-for-windows-1.2.2-install/lib64 )
# if we found the library, add it to the defined libraries
IF ( SUITESPARSE_LIBRARY_DIRS )
if ( EXISTS "${SUITESPARSE_LIBRARY_DIRS}/libamd.lib" )
list ( APPEND SUITESPARSE_LIBRARY_DIRS "${SUITESPARSE_LIBRARY_DIRS}/lapack_blas_windows") # because liblapack.lib lies here
list ( APPEND SUITESPARSE_LIBRARIES optimized;libamd;optimized;libcamd;optimized;libccolamd;optimized;libcholmod;optimized;libcolamd;optimized;metis;optimized;libspqr;optimized;libumfpack;debug;libamdd;debug;libcamdd;debug;libccolamdd;debug;libcholmodd;debug;libspqrd;debug;libumfpackd;debug;libcolamdd;debug;metisd;optimized;liblapack;debug;liblapackd;optimized;suitesparseconfig;debug;suitesparseconfigd )
else()
list ( APPEND SUITESPARSE_LIBRARIES optimized;amd;optimized;camd;optimized;ccolamd;optimized;cholmod;optimized;colamd;optimized;metis;optimized;spqr;optimized;umfpack;debug;amdd;debug;camdd;debug;ccolamdd;debug;cholmodd;debug;spqrd;debug;umfpackd;debug;colamdd;debug;metisd;optimized;blas;optimized;libf2c;optimized;lapack;debug;blasd;debug;libf2cd;debug;lapackd )
endif()
if(EXISTS "${CHOLMOD_INCLUDE_DIR}/SuiteSparseQR.hpp")
SET(SUITESPARSE_SPQR_VALID TRUE CACHE BOOL "SuiteSparseSPQR valid")
else()
SET(SUITESPARSE_SPQR_VALID FALSE CACHE BOOL "SuiteSparseSPQR valid")
endif()
if(SUITESPARSE_SPQR_VALID)
FIND_LIBRARY( SUITESPARSE_SPQR_LIBRARY
NAMES libspqr
PATHS ${SUITESPARSE_LIBRARY_DIRS} )
IF (SUITESPARSE_SPQR_LIBRARY)
list ( APPEND SUITESPARSE_LIBRARIES optimized;libspqr;debug;libspqrd)
ENDIF (SUITESPARSE_SPQR_LIBRARY)
endif()
ENDIF( SUITESPARSE_LIBRARY_DIRS )
# Find cholmod part of the suitesparse library collection
# Check if the base path is set
if ( NOT CMAKE_WINDOWS_LIBS_DIR )
# This is the base directory for windows library search used in the finders we shipp.
set(CMAKE_WINDOWS_LIBS_DIR "c:/libs" CACHE STRING "Default Library search dir on windows." )
endif()
if ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 11.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2012/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 12.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2013/x32/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*Win64" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x64/")
elseif ( CMAKE_GENERATOR MATCHES "^Visual Studio 14.*" )
SET(VS_SEARCH_PATH "${CMAKE_WINDOWS_LIBS_DIR}/vs2015/x32/")
endif()
FIND_PATH( CHOLMOD_INCLUDE_DIR cholmod.h
PATHS "C:\\libs\\win32\\SuiteSparse\\Include"
"${VS_SEARCH_PATH}"
PATH_SUFFIXES suitesparse-4.2.1/include/suitesparse
suitesparse-metis-for-windows-1.2.2-install/include/suitesparse
)
# Add cholmod include directory to collection include directories
if ( CHOLMOD_INCLUDE_DIR )
list ( APPEND SUITESPARSE_INCLUDE_DIRS ${CHOLMOD_INCLUDE_DIR} )
endif( CHOLMOD_INCLUDE_DIR )
# find path suitesparse library
FIND_PATH( SUITESPARSE_LIBRARY_DIRS
NAMES amd.lib libamd.lib
PATHS "C:\\libs\\win32\\SuiteSparse\\libs"
"${VS_SEARCH_PATH}"
PATH_SUFFIXES suitesparse-4.2.1/lib64
suitesparse-metis-for-windows-1.2.2-install/lib64 )
# if we found the library, add it to the defined libraries
if ( SUITESPARSE_LIBRARY_DIRS )
if ( EXISTS "${SUITESPARSE_LIBRARY_DIRS}/libamd.lib" )
list ( APPEND SUITESPARSE_LIBRARY_DIRS "${SUITESPARSE_LIBRARY_DIRS}/lapack_blas_windows") # because liblapack.lib lies here
list ( APPEND SUITESPARSE_LIBRARIES optimized;libamd;optimized;libcamd;optimized;libccolamd;optimized;libcholmod;optimized;libcolamd;optimized;metis;optimized;libspqr;optimized;libumfpack;debug;libamdd;debug;libcamdd;debug;libccolamdd;debug;libcholmodd;debug;libspqrd;debug;libumfpackd;debug;libcolamdd;debug;metisd;optimized;liblapack;debug;liblapackd;optimized;suitesparseconfig;debug;suitesparseconfigd )
else()
list ( APPEND SUITESPARSE_LIBRARIES optimized;amd;optimized;camd;optimized;ccolamd;optimized;cholmod;optimized;colamd;optimized;metis;optimized;spqr;optimized;umfpack;debug;amdd;debug;camdd;debug;ccolamdd;debug;cholmodd;debug;spqrd;debug;umfpackd;debug;colamdd;debug;metisd;optimized;blas;optimized;libf2c;optimized;lapack;debug;blasd;debug;libf2cd;debug;lapackd )
endif()
if(EXISTS "${CHOLMOD_INCLUDE_DIR}/SuiteSparseQR.hpp")
SET(SUITESPARSE_SPQR_VALID TRUE CACHE BOOL "SuiteSparseSPQR valid")
else()
SET(SUITESPARSE_SPQR_VALID FALSE CACHE BOOL "SuiteSparseSPQR valid")
endif()
if(SUITESPARSE_SPQR_VALID)
FIND_LIBRARY( SUITESPARSE_SPQR_LIBRARY
NAMES libspqr
PATHS ${SUITESPARSE_LIBRARY_DIRS} )
if (SUITESPARSE_SPQR_LIBRARY)
list ( APPEND SUITESPARSE_LIBRARIES optimized;libspqr;debug;libspqrd)
else(SUITESPARSE_SPQR_LIBRARY)
SET(SUITESPARSE_SPQR_VALID FALSE)
endif (SUITESPARSE_SPQR_LIBRARY)
endif()
endif( SUITESPARSE_LIBRARY_DIRS )
else( WIN32 )
IF( APPLE)
FIND_PATH( CHOLMOD_INCLUDE_DIR cholmod.h
PATHS /opt/local/include/ufsparse )
FIND_PATH( SUITESPARSE_LIBRARY_DIR
NAMES libSuiteSparse.dylib
PATHS /opt/local/lib )
list ( APPEND SUITESPARSE_LIBRARY_DIRS ${SUITESPARSE_LIBRARY_DIR} )
list ( APPEND SUITESPARSE_LIBRARIES SuiteSparse)
ELSE(APPLE)
FIND_PATH( CHOLMOD_INCLUDE_DIR cholmod.h
PATHS /usr/local/include
/usr/include
/usr/include/suitesparse/
${CMAKE_SOURCE_DIR}/MacOS/Libs/cholmod
PATH_SUFFIXES cholmod/ CHOLMOD/ )
FIND_PATH( SUITESPARSE_LIBRARY_DIR
NAMES libcholmod.so
PATHS /usr/lib
/usr/lib64
/usr/local/lib
/usr/lib/x86_64-linux-gnu )
ENDIF(APPLE)
# Add cholmod include directory to collection include directories
IF ( CHOLMOD_INCLUDE_DIR )
list ( APPEND SUITESPARSE_INCLUDE_DIRS ${CHOLMOD_INCLUDE_DIR} )
ENDIF( CHOLMOD_INCLUDE_DIR )
# if we found the library, add it to the defined libraries
IF ( SUITESPARSE_LIBRARY_DIR )
# Skipped, as this is set for apple in the block above
# if (NOT APPLE)
list ( APPEND SUITESPARSE_LIBRARIES amd)
list ( APPEND SUITESPARSE_LIBRARIES btf)
list ( APPEND SUITESPARSE_LIBRARIES camd)
list ( APPEND SUITESPARSE_LIBRARIES ccolamd)
list ( APPEND SUITESPARSE_LIBRARIES cholmod)
list ( APPEND SUITESPARSE_LIBRARIES colamd)
# list ( APPEND SUITESPARSE_LIBRARIES csparse)
list ( APPEND SUITESPARSE_LIBRARIES cxsparse)
list ( APPEND SUITESPARSE_LIBRARIES klu)
# list ( APPEND SUITESPARSE_LIBRARIES spqr)
list ( APPEND SUITESPARSE_LIBRARIES umfpack)
# endif()
# Metis and spqr are optional
FIND_LIBRARY( SUITESPARSE_METIS_LIBRARY
NAMES metis
PATHS ${SUITESPARSE_LIBRARY_DIR} )
IF (SUITESPARSE_METIS_LIBRARY)
list ( APPEND SUITESPARSE_LIBRARIES ${SUITESPARSE_METIS_LIBRARY})
ENDIF(SUITESPARSE_METIS_LIBRARY)
if(EXISTS "${CHOLMOD_INCLUDE_DIR}/SuiteSparseQR.hpp")