Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support Ubuntu 18.04 and Centos7 #4614

Merged
merged 16 commits into from
Jun 23, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
97 changes: 56 additions & 41 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,43 @@ else()
set(ABOUT_COMPILER "${CMAKE_CXX_COMPILER_ID}")
endif()

# If Linux, check LSB_RELEASE globally so we can use it after
# But also infer the new E+ package names (starting at 9.4.0)
if(APPLE)

set(ENERGYPLUS_SYSTEM_VERSION "")

find_program(UNAME uname)
execute_process(COMMAND ${UNAME} -m
OUTPUT_VARIABLE ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

elseif(UNIX)
# OS_RELEASE is the result of `uname -r` which is unhelpful (eg '5.4.0-42-generic')
find_program(LSB_RELEASE lsb_release)
# -rs outputs only 16.04, or 18.04
execute_process(COMMAND ${LSB_RELEASE} -rs
OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# -is outputs "Ubuntu" or "Fedora"
execute_process(COMMAND ${LSB_RELEASE} -is
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# eg: `-Ubuntu18.04`
set(ENERGYPLUS_SYSTEM_VERSION "-${LSB_RELEASE_ID_SHORT}${LSB_RELEASE_VERSION_SHORT}")

message(STATUS "LSB_RELEASE_ID_SHORT=${LSB_RELEASE_ID_SHORT}, LSB_RELEASE_VERSION_SHORT=${LSB_RELEASE_VERSION_SHORT}")

elseif(MSVC)
# no-op
set(ENERGYPLUS_SYSTEM_VERSION "")
endif()

###############################################################################

###############################################################################
Expand Down Expand Up @@ -544,42 +581,7 @@ endif()
###############################################################################
# Dependencies

# If Linux, check LSB_RELEASE globally so we can use it after
# But also infer the new E+ package names (starting at 9.4.0)
if(APPLE)

set(ENERGYPLUS_SYSTEM_VERSION "")

find_program(UNAME uname)
execute_process(COMMAND ${UNAME} -m
OUTPUT_VARIABLE ARCH
OUTPUT_STRIP_TRAILING_WHITESPACE
)

elseif(UNIX)
# OS_RELEASE is the result of `uname -r` which is unhelpful (eg '5.4.0-42-generic')
find_program(LSB_RELEASE lsb_release)
# -rs outputs only 16.04, or 18.04
execute_process(COMMAND ${LSB_RELEASE} -rs
OUTPUT_VARIABLE LSB_RELEASE_VERSION_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# -is outputs "Ubuntu" or "Fedora"
execute_process(COMMAND ${LSB_RELEASE} -is
OUTPUT_VARIABLE LSB_RELEASE_ID_SHORT
OUTPUT_STRIP_TRAILING_WHITESPACE
)

# eg: `-Ubuntu18.04`
set(ENERGYPLUS_SYSTEM_VERSION "-${LSB_RELEASE_ID_SHORT}${LSB_RELEASE_VERSION_SHORT}")

message(STATUS "LSB_RELEASE_ID_SHORT=${LSB_RELEASE_ID_SHORT}, LSB_RELEASE_VERSION_SHORT=${LSB_RELEASE_VERSION_SHORT}")

elseif(MSVC)
# no-op
set(ENERGYPLUS_SYSTEM_VERSION "")
endif()

# EnergyPlus

Expand All @@ -592,10 +594,10 @@ if(UNIX)
set(ENERGYPLUS_EXPECTED_HASH a8b7727f57273d6e80c5763b1c73945d)
set(ENERGYPLUS_PLATFORM "Darwin-macOS10.15-x86_64")
endif()
elseif(EXISTS "/etc/redhat-release")
elseif(LSB_RELEASE_ID_SHORT MATCHES "CentOS")
# TODO: There aren't any redhat releases anymore, see PR #3145 too
set(ENERGYPLUS_EXPECTED_HASH DOES_NOT_EXIST_02ed618aab65bf46c96bf1faf2e1905b)
set(ENERGYPLUS_PLATFORM "Redhat-x86_64")
set(ENERGYPLUS_EXPECTED_HASH b39f88c94e33b462cd1939df13b241d2)
set(ENERGYPLUS_PLATFORM "Centos7-x86_64")
else()
if(LSB_RELEASE_VERSION_SHORT MATCHES "20.04")
set(ENERGYPLUS_EXPECTED_HASH 70dde5907e3e7f6aeee45bdff5145bc2)
Expand All @@ -612,7 +614,7 @@ if(UNIX)
message(STATUS "Downloading EnergyPlus ${ENERGYPLUS_VERSION} (${ENERGYPLUS_PLATFORM})")
message(STATUS "https://github.com/NREL/EnergyPlus/releases/download/${ENERGYPLUS_RELEASE_NAME}/${ENERGYPLUS_PATH}.tar.gz") # TODO: Temp: custom build on my fork

if(EXISTS "/etc/redhat-release")
if(LSB_RELEASE_ID_SHORT MATCHES "CentOS")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/${ENERGYPLUS_PATH}.tar.gz" "${PROJECT_BINARY_DIR}/${ENERGYPLUS_PATH}.tar.gz"
INACTIVITY_TIMEOUT 300 # 5-min timeout
SHOW_PROGRESS
Expand Down Expand Up @@ -716,7 +718,7 @@ if(UNIX)
endif()
if(NOT EXISTS "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz" OR NOT "${RADIANCE_HASH}" MATCHES "${RADIANCE_EXPECTED_HASH}")
message(STATUS "Downloading Radiance ${RADIANCE_VERSION} (${RADIANCE_PLATFORM})")
if(EXISTS "/etc/redhat-release")
if(EXISTS "/etc/redhat-release" OR LSB_RELEASE_ID_SHORT MATCHES "CentOS")
message("http://openstudio-resources.s3.amazonaws.com/dependencies/radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}.tar.gz")
file(DOWNLOAD "http://openstudio-resources.s3.amazonaws.com/dependencies/radiance-${RADIANCE_VERSION}-${RADIANCE_PLATFORM}.tar.gz" "${PROJECT_BINARY_DIR}/${RADIANCE_PATH}.tar.gz" TIMEOUT 120 INACTIVITY_TIMEOUT 120 SHOW_PROGRESS EXPECTED_MD5 ${RADIANCE_EXPECTED_HASH})
else()
Expand Down Expand Up @@ -1244,10 +1246,13 @@ set(CPACK_PACKAGE_VERSION_PATCH ${OpenStudio_VERSION_PATCH}) # This one includes
# set(CPACK_DEBIAN_PACKAGE_DEPENDS "")

# Default the debian package name to include version to allow several versions to be installed concurrently instead of overwriting any existing one
# CMAKE_PROJECT_HOMEPAGE_URL
set(CPACK_DEBIAN_PACKAGE_NAME "openstudio-${OpenStudio_VERSION}")
set(CPACK_RPM_PACKAGE_NAME "openstudio-${OpenStudio_VERSION}")
# CPACK_DEBIAN_PACKAGE_DESCRIPTION defaults to this one too. dpkg-deb -I xxx.deb will show this description
set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenStudio is a cross-platform collection of software tools to support whole building energy modeling using EnergyPlus and advanced daylight analysis using Radiance")
set(CPACK_DEBIAN_PACKAGE_HOMEPAGE "https://www.openstudio.net")
set(CPACK_RPM_PACKAGE_URL "https://www.openstudio.net")

# The actual .deb file name on disk
set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENSTUDIO_LONG_VERSION}-${CMAKE_SYSTEM_NAME}")
Expand All @@ -1263,6 +1268,9 @@ elseif(UNIX)
# These two will set the .deb install path correctly
set(CPACK_SET_DESTDIR ON)
set(CPACK_INSTALL_PREFIX /usr/local/openstudio-${OpenStudio_VERSION}/)
if(LSB_RELEASE_ID_SHORT MATCHES "CentOS")
set(CPACK_RPM_PACKAGE_RELOCATABLE OFF)
endif()

# Add a symlink to the CLI: /usr/local/bin/openstudio should point to /usr/local/openstudio-${OpenStudio_VERSION}/bin/openstudio,
# UNLESS it's from the OpenStudioApplication
Expand All @@ -1284,7 +1292,8 @@ elseif(UNIX)
execute_process(COMMAND chmod 755 "${POSTRM_FILE}")

set(CPACK_DEBIAN_PACKAGE_CONTROL_EXTRA "${CPACK_DEBIAN_BIN_PACKAGE_CONTROL_EXTRA};${POSTINST_FILE};${POSTRM_FILE}")

set(CPACK_RPM_POST_INSTALL_SCRIPT_FILE "${POSTINST_FILE}")
set(CPACK_RPM_POST_UNINSTALL_SCRIPT_FILE "${POSTRM_FILE}")
endif()

# TODO: for now since Mac and Windows installers aren't doing it for core, not doing it for Unix either.
Expand All @@ -1310,6 +1319,12 @@ if(WIN32)
set(CPACK_BINARY_NSIS OFF CACHE BOOL "Enable to build NSIS packages")
endif()

if(LSB_RELEASE_ID_SHORT MATCHES "CentOS")
set(CPACK_RPM_SPEC_MORE_DEFINE "%define __python python3")
# tk (wish), tcsh and perl for radiance
set(CPACK_RPM_PACKAGE_REQUIRES "libicu libicu-devel tk tcsh perl")
endif()

message(STATUS "Installer name is set to '${CPACK_PACKAGE_FILE_NAME}'")

if (BUILD_CLI)
Expand Down
43 changes: 36 additions & 7 deletions ConanInstall.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ if(NOT CONAN_OPENSTUDIO_ALREADY_RUN)
NAME nrel INDEX 0 URL
https://conan.openstudio.net/artifactory/api/conan/openstudio)

conan_add_remote(
NAME bincrafters URL
https://bincrafters.jfrog.io/artifactory/api/conan/public-conan)

#conan_add_remote(NAME jmarrec
# URL https://api.bintray.com/conan/jmarrec/testing)
# conan_add_remote(
# NAME bincrafters URL
# https://bincrafters.jfrog.io/artifactory/api/conan/public-conan)

# Enable revisions in conan: check if they are already enabled, if not do it and warn user
execute_process(
Expand Down Expand Up @@ -81,8 +78,40 @@ if(NOT CONAN_OPENSTUDIO_ALREADY_RUN)

if(BUILD_RUBY_BINDINGS OR BUILD_CLI)
# Track NREL/stable in general, on a feature branch this could be temporarily switched to NREL/testing
set(CONAN_RUBY "openstudio_ruby/2.7.2@nrel/testing#98444b7bc8d391ea1521d7f79d4d4926")
set(CONAN_RUBY "openstudio_ruby/2.7.2@nrel/stable#ae043c41b4bec82e98ca765ce8b32a11")
endif()

if(LSB_RELEASE_ID_SHORT MATCHES "CentOS")
# Use this specific remote where I uploaded the centos-build packages
# The os is still Linux, the compiler is still GCC. But the GLIBC used is **way older**
#conan_add_remote(NAME openstudio-centos INDEX 0
# URL https://conan.openstudio.net/artifactory/api/conan/openstudio-centos)

# Pass `-D_GLIBCXX_USE_CXX11_ABI=0` to make sure it detects libstdc++ and not libstdc++1
add_definitions(-D_GLIBCXX_USE_CXX11_ABI=0)
endif()

# Build ALL dependencies to avoid problems with the way too old CentOS GLIBC
# Ubuntu 20.04 has GLIBC 2.31
# Ubuntu 18.04 has GLIBC 2.27
# Centos7 has GLIBC 2.17
if(DEFINED CONAN_FIRST_TIME_BUILD_ALL)
if(CONAN_FIRST_TIME_BUILD_ALL)
message("FIRST TIME: FORCE BUILDING ALL CONAN PACKAGES")
# TODO: Try to avoid rebuilding everything...?
set(CONAN_BUILD "all") # This works, but it's gonna be sloooowww
# if(LSB_RELEASE_ID_SHORT MATCHES "Ubuntu" AND LSB_RELEASE_VERSION_SHORT MATCHES "18.04")
# # build only the ones that are problematic
# # boost: undefined reference to statx
# list(APPEND CONAN_BUILD "boost")
# # This isn't enough for Ubuntu 18.04, I also get another issue: undefined reference to fnctl64 (fnctl -> fnclt64 happened in GLIBC 2.28) when linking libopenstudio.lib
# # but I do not know which package it's coming from
# endif()
# Force switch it off for the next time
set(CONAN_FIRST_TIME_BUILD_ALL OFF CACHE BOOL OFF FORCE)
endif()
endif()
message("CONAN_BUILD=${CONAN_BUILD}")

if(BUILD_BENCHMARK)
set(CONAN_BENCHMARK "benchmark/1.6.1#94c40ebf065e3b20cab6a4f1b03a65fe")
Expand Down