Skip to content

Commit

Permalink
simplifies findEurostag: no need to set an explicit eurostag_version …
Browse files Browse the repository at this point in the history
…variable
  • Loading branch information
Christian Biasuzzi committed Aug 2, 2017
1 parent efbc29a commit a851676
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 31 deletions.
57 changes: 29 additions & 28 deletions cmake/FindEurostag.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -23,49 +23,46 @@ if (NOT EUROSTAG_SDK_HOME)
message(FATAL_ERROR "Eurostag SDK not found. The variable EUROSTAG_SDK_HOME is NOT set or is NOT a valid directory")
endif()

if (NOT EUROSTAG_VERSION AND NOT $ENV{EUROSTAG_VERSION} STREQUAL "")
set(EUROSTAG_VERSION $ENV{EUROSTAG_VERSION})
endif()

if (NOT EUROSTAG_VERSION)
message(WARNING "Eurostag SDK version not specified. Assuming a 5.1 default")
set(EUROSTAG_VERSION "5.1")
endif()


find_path(Eurostag_INCLUDE_DIR NAME api_eurostag.h HINTS ${EUROSTAG_SDK_HOME}/include NO_DEFAULT_PATH)
mark_as_advanced(Eurostag_INCLUDE_DIR)

if (EUROSTAG_VERSION STREQUAL "5.1")
# Note that EUROSTAG SDK v5.1 provides only static libraries, whereas v5.2 provides only dynamic libraries.
if (EXISTS "${EUROSTAG_SDK_HOME}/lib/libeustag_esg.so")
set(EUROSTAG_DYNAMIC_LIBS true)
set(components
eustag_esg eustag_cpt
eustag_a light_lib_a_t
eustag_i
eustag_s light_lib_s
eustag_lf
light_lib_t_s light_lib_t
eustag_bld
util klu amd
eustag_esg
)
elseif(EUROSTAG_VERSION STREQUAL "5.2")
else()
set(EUROSTAG_DYNAMIC_LIBS false)
set(components
eustag_esg
eustag_esg
eustag_cpt
eustag_a
light_lib_a_t
eustag_i
eustag_s
light_lib_s
eustag_lf
light_lib_t_s
light_lib_t
eustag_bld
util
klu
amd
)
else()
message(FATAL_ERROR "Eurostag version ${EUROSTAG_VERSION} not supported")
endif()

include(FindPackageHandleStandardArgs)
foreach(component ${components})
string(TOUPPER ${component} COMPONENT)
set(Eurostag_${component}_FIND_QUIETLY true)

if (EUROSTAG_VERSION STREQUAL "5.1")
find_library(Eurostag_${component}_LIBRARY lib${component}.a HINTS ${EUROSTAG_SDK_HOME}/lib NO_DEFAULT_PATH)
else()
if (EUROSTAG_DYNAMIC_LIBS)
find_library(Eurostag_${component}_LIBRARY ${component} HINTS ${EUROSTAG_SDK_HOME}/lib NO_DEFAULT_PATH)
else()
find_library(Eurostag_${component}_LIBRARY lib${component}.a HINTS ${EUROSTAG_SDK_HOME}/lib NO_DEFAULT_PATH)
endif()

mark_as_advanced(Eurostag_${component}_LIBRARY)
find_package_handle_standard_args(Eurostag_${component} DEFAULT_MSG Eurostag_${component}_LIBRARY)

Expand All @@ -84,5 +81,9 @@ endforeach()
set(Eurostag_FOUND true)
set(Eurostag_INCLUDE_DIRS ${Eurostag_INCLUDE_DIR})
message(STATUS "Eurostag SDK found: ${EUROSTAG_SDK_HOME}")
message(STATUS "Eurostag SDK version: ${EUROSTAG_VERSION}")
if (EUROSTAG_DYNAMIC_LIBS)
message(STATUS "Eurostag SDK: linking to dynamic libraries")
else()
message(STATUS "Eurostag SDK: linking to static libraries")
endif()

4 changes: 1 addition & 3 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@ dymola_build=false
dymola_home=
eurostag_build=false
eurostag_home=
eurostag_version=
matlab_build=false
matlab_home=

Expand Down Expand Up @@ -121,7 +120,6 @@ writeSettings() {
writeComment " -- iPST C++ modules options --"
writeSetting "eurostag_build" ${eurostag_build}
writeSetting "eurostag_home" "${eurostag_home}"
writeSetting "eurostag_version" "${eurostag_version}"
writeSetting "dymola_build" ${dymola_build}
writeSetting "dymola_home" "${dymola_home}"
writeSetting "matlab_build" ${matlab_build}
Expand Down Expand Up @@ -182,7 +180,7 @@ ipst_cpp()

if [[ $ipst_compile = true || $ipst_docs = true ]]; then
# TODO: rename variable
cmake -DCMAKE_INSTALL_PREFIX="$ipst_prefix" -Dthirdparty_prefix="$thirdparty_prefix" -DBUILD_EUROSTAG=$eurostag_build -DEUROSTAG_SDK_HOME="${eurostag_home}" -DEUROSTAG_VERSION="${eurostag_version}" -DBUILD_MATLAB=$matlab_build -DMATLAB_HOME="${matlab_home}" -DBUILD_DYMOLA=$dymola_build -DDYMOLA_HOME="${dymola_home}" -G "Unix Makefiles" -H"$sourceDir" -B"$ipst_builddir" || exit $?
cmake -DCMAKE_INSTALL_PREFIX="$ipst_prefix" -Dthirdparty_prefix="$thirdparty_prefix" -DBUILD_EUROSTAG=$eurostag_build -DEUROSTAG_SDK_HOME="${eurostag_home}" -DBUILD_MATLAB=$matlab_build -DMATLAB_HOME="${matlab_home}" -DBUILD_DYMOLA=$dymola_build -DDYMOLA_HOME="${dymola_home}" -G "Unix Makefiles" -H"$sourceDir" -B"$ipst_builddir" || exit $?

if [ $ipst_compile = true ]; then
echo "**** Compiling C++ modules"
Expand Down

0 comments on commit a851676

Please sign in to comment.