diff --git a/.github/workflows/app_build.yml b/.github/workflows/app_build.yml index 9a201dd1b..93fafaf4c 100644 --- a/.github/workflows/app_build.yml +++ b/.github/workflows/app_build.yml @@ -15,22 +15,7 @@ env: BUILD_TESTING: ON BUILD_BENCHMARK: ON BUILD_PACKAGE: ON - CPACK_BINARY_NSIS: OFF - CPACK_BINARY_RPM: OFF - CPACK_BINARY_STGZ: OFF - CPACK_BINARY_TBZ2: OFF - CPACK_BINARY_TGZ: ON - CPACK_BINARY_TXZ: OFF - CPACK_BINARY_TZ: OFF - CPACK_SOURCE_RPM: OFF - CPACK_SOURCE_TBZ2: OFF - CPACK_SOURCE_TGZ: OFF - CPACK_SOURCE_TXZ: OFF - CPACK_SOURCE_TZ: OFF - CPACK_SOURCE_ZIP: OFF QT_VERSION: 6.6.3 - # CPACK_BINARY_DEB: OS-SPECIFIC - # CPACK_BINARY_IFW: OS-SPECIFIC jobs: build: @@ -47,10 +32,6 @@ jobs: - os: ubuntu-20.04 SELF_HOSTED: false PLATFORM_NAME: Linux - CPACK_BINARY_DEB: ON - CPACK_BINARY_IFW: OFF - CPACK_BINARY_TGZ: ON - CPACK_BINARY_ZIP: OFF BINARY_EXT: deb COMPRESSED_EXT: tar.gz BINARY_PKG_PATH: _CPack_Packages/Linux/DEB @@ -60,10 +41,6 @@ jobs: - os: ubuntu-22.04 SELF_HOSTED: false PLATFORM_NAME: Linux - CPACK_BINARY_DEB: ON - CPACK_BINARY_IFW: OFF - CPACK_BINARY_TGZ: ON - CPACK_BINARY_ZIP: OFF BINARY_EXT: deb COMPRESSED_EXT: tar.gz BINARY_PKG_PATH: _CPack_Packages/Linux/DEB @@ -73,10 +50,6 @@ jobs: - os: windows-2022 SELF_HOSTED: false PLATFORM_NAME: Windows - CPACK_BINARY_DEB: OFF - CPACK_BINARY_IFW: ON - CPACK_BINARY_TGZ: OFF - CPACK_BINARY_ZIP: ON BINARY_EXT: exe COMPRESSED_EXT: zip BINARY_PKG_PATH: _CPack_Packages/win64/IFW @@ -86,10 +59,6 @@ jobs: - os: macos-13 SELF_HOSTED: false PLATFORM_NAME: Darwin - CPACK_BINARY_DEB: OFF - CPACK_BINARY_IFW: ON - CPACK_BINARY_TGZ: ON - CPACK_BINARY_ZIP: OFF BINARY_EXT: dmg COMPRESSED_EXT: tar.gz BINARY_PKG_PATH: _CPack_Packages/Darwin/IFW @@ -101,10 +70,6 @@ jobs: - os: macos-arm64 SELF_HOSTED: true PLATFORM_NAME: Darwin - CPACK_BINARY_DEB: OFF - CPACK_BINARY_IFW: ON - CPACK_BINARY_TGZ: ON - CPACK_BINARY_ZIP: OFF BINARY_EXT: dmg COMPRESSED_EXT: tar.gz BINARY_PKG_PATH: _CPack_Packages/Darwin/IFW @@ -126,7 +91,7 @@ jobs: - uses: ruby/setup-ruby@v1 if: ${{ !matrix.SELF_HOSTED }} with: - ruby-version: 2.7 + ruby-version: 3.2.2 - name: Extract OSApp and OS SDK versions from CMakeLists.txt shell: bash @@ -142,25 +107,19 @@ jobs: set -x pwd echo PLATFORM_NAME=${{ matrix.PLATFORM_NAME }} >> $GITHUB_ENV - echo CPACK_BINARY_DEB=${{ matrix.CPACK_BINARY_DEB }} >> $GITHUB_ENV - echo CPACK_BINARY_IFW=${{ matrix.CPACK_BINARY_IFW }} >> $GITHUB_ENV - echo CPACK_BINARY_ZIP=${{ matrix.CPACK_BINARY_ZIP }} >> $GITHUB_ENV - echo CPACK_BINARY_TGZ=${{ matrix.CPACK_BINARY_TGZ }} >> $GITHUB_ENV echo BINARY_EXT=${{ matrix.BINARY_EXT }} >> $GITHUB_ENV echo COMPRESSED_EXT=${{ matrix.COMPRESSED_EXT }} >> $GITHUB_ENV - if [ "${{ matrix.SELF_HOSTED }}" == "true" ]; then - echo CONAN_PROFILE_DEFAULT=$HOME/.conan/profiles/default >> $GITHUB_ENV - elif [ "$RUNNER_OS" == "Windows" ]; then - echo CONAN_USER_HOME="${{ github.workspace }}\conan-cache" >> $GITHUB_ENV - echo CONAN_USER_HOME_SHORT="${{ github.workspace }}\conan-cache\short" >> $GITHUB_ENV - echo CONAN_PROFILE_DEFAULT="${{ github.workspace }}\conan-cache\.conan\profiles\default" >> $GITHUB_ENV - CCACHE_DIR="${{ github.workspace }}\.ccache" - echo CCACHE_DIR=$CCACHE_DIR >> $GITHUB_ENV + + if [ "$RUNNER_OS" == "Windows" ]; then + DIR_SEP="\\" else - echo CONAN_USER_HOME=${{ github.workspace }}/conan-cache >> $GITHUB_ENV - echo CONAN_USER_HOME_SHORT=${{ github.workspace }}/conan-cache/short >> $GITHUB_ENV - echo CONAN_PROFILE_DEFAULT=${{ github.workspace }}/conan-cache/.conan/profiles/default >> $GITHUB_ENV - CCACHE_DIR=${{ github.workspace }}/.ccache + DIR_SEP="/" + fi + + echo DIR_SEP=$DIR_SEP >> $GITHUB_ENV + + if [ "${{ matrix.SELF_HOSTED }}" != "true" ]; then + CCACHE_DIR="${{ github.workspace }}${DIR_SEP}.ccache" echo CCACHE_DIR=$CCACHE_DIR >> $GITHUB_ENV fi @@ -256,20 +215,53 @@ jobs: - name: Install conan shell: bash run: | + begin_group() { echo -e "::group::\033[93m$1\033[0m"; } + set -x + begin_group "Install conan 2" python --version - pip install 'conan<2' + pip install 'conan>2' conan --version - echo "Enabling conan revisions and setting parallel_download" - conan config set general.revisions_enabled=True - conan config set general.parallel_download=8 - # We detect the profile and use that as one of the cache key parameters, so if GHA upgrades compilers it won't pick up old binaries - conan profile new --detect --force default - if [ "$RUNNER_OS" == "Linux" ]; then - conan profile update settings.compiler.libcxx=libstdc++11 default - fi - conan profile show default + echo "::endgroup::" + begin_group "Default profile" + if [ "${{ matrix.SELF_HOSTED }}" == "true" ]; then + export CONAN_USER_HOME=$HOME + else + export CONAN_USER_HOME="${{ github.workspace }}${DIR_SEP}conan-cache" + fi; + echo CONAN_USER_HOME="$CONAN_USER_HOME" >> $GITHUB_ENV + + export CONAN_HOME="$CONAN_USER_HOME${DIR_SEP}.conan2" + echo CONAN_HOME="$CONAN_HOME" >> $GITHUB_ENV + + export CONAN_PROFILE_DEFAULT="$CONAN_HOME${DIR_SEP}profiles${DIR_SEP}default" + echo CONAN_PROFILE_DEFAULT="$CONAN_PROFILE_DEFAULT" >> $GITHUB_ENV + + conan profile detect --force --name default + cat $CONAN_PROFILE_DEFAULT + # Mac has the FreeBSD flavor of sed and MUST take a backup suffix... + sed -i.bak 's/cppstd=.*$/cppstd=20/g' $CONAN_PROFILE_DEFAULT + sed -i.bak 's/build_type=.*$/build_type=${{ env.BUILD_TYPE }}/g' $CONAN_PROFILE_DEFAULT + # Windows only + sed -i.bak 's/compiler.runtime_type=.*$/compiler.runtime_type=${{ env.BUILD_TYPE }}/g' $CONAN_PROFILE_DEFAULT + rm -Rf $CONAN_PROFILE_DEFAULT.bak || true + conan profile show + echo "::endgroup::" + + begin_group "Global.conf" + echo "core:non_interactive = True" >> $CONAN_HOME/global.conf + echo "core.download:parallel = {{os.cpu_count() - 2}}" >> $CONAN_HOME/global.conf + echo "core.sources:download_cache = $CONAN_USER_HOME/.conan-download-cache" >> $CONAN_HOME/global.conf + cat $CONAN_HOME/global.conf + echo "::endgroup::" + + begin_group "Remotes" + conan remote add --force nrel-v2 https://conan.openstudio.net/artifactory/api/conan/conan-v2 + conan remote list + echo "::endgroup::" + + begin_group "Debug hashFiles and co" if [ "${{ matrix.SELF_HOSTED }}" == "false" ]; then echo "runner.workspace=${{ runner.workspace }}" echo "GITHUB_WORKSPACE=$GITHUB_WORKSPACE" @@ -282,16 +274,17 @@ jobs: echo hashFiles_rel=${{ hashFiles('./conan-cache/.conan/profiles/default') }} echo hashFiles_conanInstall=${{ hashFiles('./ConanInstall.cmake') }} fi + echo "::endgroup::" - # Note: I'm picking up the ccache before I do the conan cache, otheriwe on windows when trying to hashFiles('**/CMakeLists.txt') it looks into the conan folder which fails + # Note: I'm picking up the ccache before I do the conan cache, otherwise on windows when trying to hashFiles('**/CMakeLists.txt') it looks into the conan folder which fails # To prevent problems, changing to multiple more specific glob patterns - name: Setup CCache - uses: actions/cache@v3 + uses: actions/cache@v4 id: cacheccache if: ${{ !matrix.SELF_HOSTED }} with: path: | - ${{ env.CCACHE_DIR}} + ${{ env.CCACHE_DIR }} key: ccache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-ck=${{ secrets.CACHE_KEY }}-cmakelists=${{ hashFiles('CMakeLists.txt', 'src/*/CMakeLists.txt', '*/CMakeLists.txt') }} restore-keys: | ccache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-ck=${{ secrets.CACHE_KEY }}- @@ -305,15 +298,17 @@ jobs: ccache --zero-stats - name: Setup Conan Cache - uses: actions/cache@v3 + uses: actions/cache@v4 id: cacheconan if: ${{ !matrix.SELF_HOSTED }} with: path: | ${{ env.CONAN_USER_HOME }} - key: conan-cache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-ck=${{ secrets.CACHE_KEY }}-conaninstall=${{ hashFiles('./ConanInstall.cmake') }} + key: conan-cache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-conaninstall=${{ hashFiles('./conanfile.py') }}-ck=${{ secrets.CACHE_KEY }} restore-keys: | - conan-cache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-ck=${{ secrets.CACHE_KEY }}- + conan-cache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}-conaninstall=${{ hashFiles('./conanfile.py') }}- + conan-cache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}-conan-profile=${{ hashFiles(env.CONAN_PROFILE_DEFAULT) }}- + conan-cache-${{ matrix.os }}-build=${{ env.BUILD_TYPE }}- - name: Did restoring the conan-cache work? Yes # If the SDK wasn't found in the cache @@ -321,14 +316,21 @@ jobs: working-directory: ${{ env.CONAN_USER_HOME }} shell: bash run: | - cat $CONAN_USER_HOME/.conan/profiles/default - ls $CONAN_USER_HOME/.conan/data - ls $CONAN_USER_HOME/short || true + set -x + set +e + cat $CONAN_PROFILE_DEFAULT + ls $CONAN_HOME + ls $CONAN_USER_HOME/.conan-download-cache + cat $CONAN_HOME/global.conf + ls $CONAN_USER_HOME/short + conan config show core.download:download_cache + conan config show core.sources:download_cache + exit 0 # This includes the Qt install, the OpenStudio SDK tar.gz, # TODO: problem is that caching the entire build dir is limited to 10 GB. The build folder takes 3-4 GB per runner, and we have 4 of them that try to cache # Perhaps we should just cache the ccache. Anyways, for incremental builds triggered one after another, cache eviction hasn't happened yet and all of them do a cache hit - - name: Cache entire build directory + - name: Cache Qt and SDK id: cachebuild if: ${{ !matrix.SELF_HOSTED }} uses: actions/cache@v3 @@ -351,6 +353,7 @@ jobs: # Delete the archived OS SDK if not the expected version if [ -d "build/OpenStudio-$OS_SDK_VERSION" ]; then cd build/OpenStudio-$OS_SDK_VERSION + ls ls $OS_SDK_INSTALLER_NAME* || rm -Rf ./* fi @@ -420,29 +423,21 @@ jobs: - name: Configure CMake & build (Windows) if: runner.os == 'Windows' shell: cmd - working-directory: ./build # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 # NOTE: If you re-enable 'Download the OpenStudio installer' step, then pass `openstudio_DIR=$openstudio_DIR cmake [etc]` run: | - echo "Using vcvarsall to initialize the development environment" - call vcvarsall.bat x64 - dir - cmake -G Ninja -DQT_INSTALL_DIR:PATH=${{ env.QT_INSTALL_DIR }} -DCMAKE_BUILD_TYPE:STRING=${{ env.BUILD_TYPE }} ^ - -DBUILD_DOCUMENTATION:BOOL=${{ env.BUILD_DOCUMENTATION }} -DBUILD_TESTING:BOOL=${{ env.BUILD_TESTING }} -DBUILD_BENCHMARK:BOOL=${{ env.BUILD_BENCHMARK}} ^ - -DBUILD_PACKAGE:BOOL=${{ env.BUILD_PACKAGE }} -DCPACK_BINARY_DEB:BOOL=${{ env.CPACK_BINARY_DEB }} -DCPACK_BINARY_IFW:BOOL=${{ env.CPACK_BINARY_IFW }} ^ - -DCPACK_BINARY_NSIS:BOOL=${{ env.CPACK_BINARY_NSIS }} -DCPACK_BINARY_RPM:BOOL=${{ env.CPACK_BINARY_RPM }} -DCPACK_BINARY_STGZ:BOOL=${{ env.CPACK_BINARY_STGZ }} ^ - -DCPACK_BINARY_TBZ2:BOOL=${{ env.CPACK_BINARY_TBZ2 }} -DCPACK_BINARY_TGZ:BOOL=${{ env.CPACK_BINARY_TGZ }} -DCPACK_BINARY_ZIP:BOOL=${{ env.CPACK_BINARY_ZIP }} ^ - -DCPACK_BINARY_TXZ:BOOL=${{ env.CPACK_BINARY_TXZ }} -DCPACK_BINARY_TZ:BOOL=${{ env.CPACK_BINARY_TZ }} -DCPACK_SOURCE_RPM:BOOL=${{ env.CPACK_SOURCE_RPM }} ^ - -DCPACK_SOURCE_TBZ2:BOOL=${{ env.CPACK_SOURCE_TBZ2 }} -DCPACK_SOURCE_TGZ:BOOL=${{ env.CPACK_SOURCE_TGZ }} -DCPACK_SOURCE_TXZ:BOOL=${{ env.CPACK_SOURCE_TXZ }} ^ - -DCPACK_SOURCE_TZ:BOOL=${{ env.CPACK_SOURCE_TZ }} -DCPACK_SOURCE_ZIP:BOOL=${{ env.CPACK_SOURCE_ZIP }} ^ - -DANALYTICS_API_SECRET:STRING=${{secrets.ANALYTICS_API_SECRET }} -DANALYTICS_MEASUREMENT_ID:STRING=${{secrets.ANALYTICS_MEASUREMENT_ID }} ^ - ../ - ninja - ninja package + conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release + call ./build/conanbuild.bat + cmake --preset conan-release -DQT_INSTALL_DIR:PATH=${{ env.QT_INSTALL_DIR }} ^ + -DBUILD_DOCUMENTATION:BOOL=${{ env.BUILD_DOCUMENTATION }} ^ + -DBUILD_PACKAGE:BOOL=${{ env.BUILD_PACKAGE }} ^ + -DANALYTICS_API_SECRET:STRING=${{ secrets.ANALYTICS_API_SECRET }} ^ + -DANALYTICS_MEASUREMENT_ID:STRING=${{ secrets.ANALYTICS_MEASUREMENT_ID }} + cmake --build --preset conan-release --target package # Delete conan build and source folders - conan remove "*" -s -b -f + conan cache clean --source --build --download --temp ccache --show-stats -vv || ccache --show-stats || true # Debug CPack: @@ -451,52 +446,46 @@ jobs: - name: Configure CMake (Unix) if: runner.os != 'Windows' shell: bash - working-directory: ./build # Note the current convention is to use the -S and -B options here to specify source # and build directories, but this is only available with CMake 3.13 and higher. # The CMake binaries on the Github Actions machines are (as of this writing) 3.12 # NOTE: If you re-enable 'Download the OpenStudio installer' step, then pass `openstudio_DIR=$openstudio_DIR cmake [etc]` run: | set -x - cmake -G Ninja -DQT_INSTALL_DIR:PATH=$QT_INSTALL_DIR -DCMAKE_BUILD_TYPE:STRING=$BUILD_TYPE \ - -DBUILD_DOCUMENTATION:BOOL=$DBUILD_DOCUMENTATION -DBUILD_TESTING:BOOL=$BUILD_TESTING -DBUILD_BENCHMARK:BOOL=$BUILD_BENCHMARK \ - -DBUILD_PACKAGE:BOOL=$BUILD_PACKAGE -DCPACK_BINARY_DEB:BOOL=$CPACK_BINARY_DEB -DCPACK_BINARY_IFW:BOOL=$CPACK_BINARY_IFW \ - -DCPACK_BINARY_NSIS:BOOL=$CPACK_BINARY_NSIS -DCPACK_BINARY_RPM:BOOL=$CPACK_BINARY_RPM -DCPACK_BINARY_STGZ:BOOL=$CPACK_BINARY_STGZ \ - -DCPACK_BINARY_TBZ2:BOOL=$CPACK_BINARY_TBZ2 -DCPACK_BINARY_TGZ:BOOL=$CPACK_BINARY_TGZ -DCPACK_BINARY_ZIP:BOOL=$CPACK_BINARY_ZIP \ - -DCPACK_BINARY_TXZ:BOOL=$CPACK_BINARY_TXZ -DCPACK_BINARY_TZ:BOOL=$CPACK_BINARY_TZ -DCPACK_SOURCE_RPM:BOOL=$CPACK_SOURCE_RPM \ - -DCPACK_SOURCE_TBZ2:BOOL=$CPACK_SOURCE_TBZ2 -DCPACK_SOURCE_TGZ:BOOL=$CPACK_SOURCE_TGZ -DCPACK_SOURCE_TXZ:BOOL=$CPACK_SOURCE_TXZ \ - -DCPACK_SOURCE_TZ:BOOL=$CPACK_SOURCE_TZ -DCPACK_SOURCE_ZIP:BOOL=$CPACK_SOURCE_ZIP \ - -DANALYTICS_API_SECRET:STRING=${{secrets.ANALYTICS_API_SECRET }} -DANALYTICS_MEASUREMENT_ID:STRING=${{secrets.ANALYTICS_MEASUREMENT_ID }} \ - ../ - - # Note: JM 2020-07-22 This is an example of how to get a config log for a failed conan dependency build (no binary available) - # This WILL be handy some day, so leave it here - #- name: upload config.log for failed gdbm build - #if: ${{ failure() }} - #shell: bash - #run: | - #configlog=$(find ~/.conan/data/gdbm/1.18.1/_/_/build -name config.log) - #cat $configlog - - #- name: upload config.log for failed gdbm build - #if: ${{ failure() }} - #uses: actions/upload-artifact@v4 - #with: - #name: ${{ matrix.os }}-gdbm_config.log - #path: ~/.conan/data/gdbm/1.18.1/_/_/build/**/source_subfolder/config.log - - - name: Build (Unix) - working-directory: ./build - if: runner.os != 'Windows' - shell: bash - # Execute the build. You can specify a specific target with "--target " - run: | - set -x - ninja - ninja package || ( echo "Package Step failed" && cpack --debug --verbose --config CPackConfig.cmake ) + if [ "$RUNNER_OS" == "macOS" ]; then + # Avoid "builtin __has_nothrow_assign is deprecated; use __is_nothrow_assignable instead" in boost/1.78 with recent clang + conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release -c tools.build:cxxflags="['-D_LIBCPP_ENABLE_CXX17_REMOVED_UNARY_BINARY_FUNCTION']" + else + conan install . --output-folder=./build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release + fi + + if [ "${{ matrix.SELF_HOSTED }}" == "true" ]; then + # TODO: temp... this is unfortunate but the OS SDK arm64 rc2 package has a different sha when extracted... + # OpenStudio-3.8.0-rc2+af997f4fef-Darwin-x86_64.tar.gz on github, but when extracted it's OpenStudio-3.8.0-rc2+06d9d975e1-Darwin-arm64 + cmake --preset conan-release -DQT_INSTALL_DIR:PATH=${{ env.QT_INSTALL_DIR }} \ + -DBUILD_DOCUMENTATION:BOOL=${{ env.BUILD_DOCUMENTATION }} \ + -DBUILD_PACKAGE:BOOL=${{ env.BUILD_PACKAGE }} \ + -DANALYTICS_API_SECRET:STRING=${{ secrets.ANALYTICS_API_SECRET }} \ + -DANALYTICS_MEASUREMENT_ID:STRING=${{ secrets.ANALYTICS_MEASUREMENT_ID }} || true + + ls $(pwd)/build/OpenStudio-3.8.0 || true + OS_DIR=$(find "$(pwd)/build/OpenStudio-3.8.0" -name openstudioConfig.cmake) + OS_DIR=$(dirname $OS_DIR) + cmake --preset conan-release -DQT_INSTALL_DIR:PATH=${{ env.QT_INSTALL_DIR }} \ + -DBUILD_DOCUMENTATION:BOOL=${{ env.BUILD_DOCUMENTATION }} \ + -DBUILD_PACKAGE:BOOL=${{ env.BUILD_PACKAGE }} \ + -DANALYTICS_API_SECRET:STRING=${{ secrets.ANALYTICS_API_SECRET }} \ + -DANALYTICS_MEASUREMENT_ID:STRING=${{ secrets.ANALYTICS_MEASUREMENT_ID }} -Dopenstudio_DIR:PATH=$OS_DIR + fi + + cmake --preset conan-release -DQT_INSTALL_DIR:PATH=${{ env.QT_INSTALL_DIR }} \ + -DBUILD_DOCUMENTATION:BOOL=${{ env.BUILD_DOCUMENTATION }} \ + -DBUILD_PACKAGE:BOOL=${{ env.BUILD_PACKAGE }} \ + -DANALYTICS_API_SECRET:STRING=${{ secrets.ANALYTICS_API_SECRET }} \ + -DANALYTICS_MEASUREMENT_ID:STRING=${{ secrets.ANALYTICS_MEASUREMENT_ID }} + cmake --build --preset conan-release --target package # Delete conan build and source folders - conan remove "*" -s -b -f - # Show ccache stats + conan cache clean --source --build --download --temp ccache --show-stats -vv || ccache --show-stats || true - name: Test bed Sign inner portable executable files and exe package (Windows 2022) diff --git a/.gitignore b/.gitignore index 8403286c2..c59e93fe6 100644 --- a/.gitignore +++ b/.gitignore @@ -41,3 +41,4 @@ cppcheck.txt* clang_format.patch conan-cache .ccache +CMakeUserPresets.json diff --git a/BUILDING.md b/BUILDING.md new file mode 100644 index 000000000..ca476c508 --- /dev/null +++ b/BUILDING.md @@ -0,0 +1,135 @@ +# Building with conan v2 + +Check you have `conan >= 2`, and add the `nrel-v2` remote to grab `ruby` and `swig/4.1.1`. + +```shell +conan --version +conan remote add -f nrel-v2 http://conan.openstudio.net/artifactory/api/conan/conan-v2 +``` + +## Install the conan dependencies into a build folder + +```shell +conan install . --output-folder=../OSApp-build-release --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release +``` + +You can also do another configuration, such as `Debug`, `RelWithDeb`, etc + +```shell +conan install . --output-folder=../OSApp-build --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Debug +``` + +You'll have the `conan-release` and `conan-debug` CMake Presets in the root folder. Do `cmake --list-presets` to list the available presets (which are in `CMakeUserPresets.json`) + +*Side note:* If you want a specific configure option (such as a build folder in Release mode where you build with `-DBUILD_CSHARP_BINDINGS:BOOL=ON`) in a different build dir for the same source dir, you probably will need to go and edit the `/CMakePresets.json` to rename it to another configuration name so it does not clash with the preset `conan-release` + +## CMake Configure and build + +### With presets + +#### Why are Presets recommended + +The recommend flow is to use [CMake Presets](https://cmake.org/cmake/help/latest/manual/cmake-presets.7.html). + +If you notice the messages printed to the console when you run the `conan install` command from above, +you'll see that the `conanfile` actually defines common build variables for you already, +such as defining which `CPack` Generators to use depending on your target platform, trying to infer the `Python_ROOT_DIR` etc + +
conanfile.py: Calling generate()
+conanfile.py: Generators folder: /path/to/OSApp-build-release
+conanfile.py: Setting PYTHON_VERSION and Python_ROOT_DIR from your current python: 3.8.13, '/home/julien/.pyenv/versions/3.8.13'
+conanfile.py: CMakeToolchain generated: conan_toolchain.cmake
+conanfile.py: Preset 'conan-release' added to CMakePresets.json. Invoke it manually using 'cmake --preset conan-release' if using CMake>=3.23
+conanfile.py: If your CMake version is not compatible with CMakePresets (<3.23) call cmake like:
+    cmake <path> -G Ninja -DCMAKE_TOOLCHAIN_FILE=/path/to/OSApp-build-release/conan_toolchain.cmake \
+      -DBUILD_CLI=ON -DBUILD_RUBY_BINDINGS=ON -DBUILD_PYTHON_BINDINGS=ON \
+      -DBUILD_PYTHON_PIP_PACKAGE=OFF -DBUILD_TESTING=ON -DBUILD_BENCHMARK=ON \
+      -DCPACK_BINARY_TGZ=ON -DCPACK_BINARY_IFW=OFF -DCPACK_BINARY_DEB=ON -DCPACK_BINARY_NSIS=OFF \
+      -DCPACK_BINARY_RPM=OFF -DCPACK_BINARY_STGZ=OFF -DCPACK_BINARY_TBZ2=OFF \
+      -DCPACK_BINARY_TXZ=OFF -DCPACK_BINARY_TZ=OFF \
+      -DPYTHON_VERSION=3.8.13 -DPython_ROOT_DIR=/home/julien/.pyenv/versions/3.8.13 \
+      -DCMAKE_POLICY_DEFAULT_CMP0091=NEW -DCMAKE_BUILD_TYPE=Release
+conanfile.py: CMakeToolchain generated: CMakePresets.json
+conanfile.py: CMakeToolchain generated: ../OpenStudio/CMakeUserPresets.json
+conanfile.py: Generating aggregated env files
+conanfile.py: Generated aggregated env files: ['conanbuild.sh', 'conanrun.sh']
+Install finished successfully
+
+ +**Note that this is also supported by Visual Studio (MSVC)**. + +#### Configure and build with Presets + +Run these commands from the **source** directory (`OpenStudio/`). + +```shell +cmake --preset conan-release [any_futher_configuration_options] +``` + +Example: + +``` +cmake --preset conan-release \ + -DQT_INSTALL_DIR:PATH=/opt/Qt/6.6.3/gcc_64 \ + -DBUILD_PACKAGE:BOOL=ON +``` + +Building + +``` +cmake --build --preset conan-release +``` + +### Atlernatively: manual CMake + +First, go to the **build** directory, and **activate the conan build environment**. + +```shell +cd ../OSApp-build-release +# Unix +. ./conanbuild.sh +# Windows +call conanbuild.bat +``` + +Still in the build directory, run cmake, but do pass the `CMAKE_TOOLCHAIN_FILE` + +``` +cmake -G Ninja -DCMAKE_TOOLCHAIN_FILE=conan_toolchain.cmake -DCMAKE_BUILD_TYPE:STRING=Release \ + -DQT_INSTALL_DIR:PATH=/opt/Qt/6.6.3/gcc_64 \ + -DBUILD_TESTING:BOOL=ON -DCPACK_BINARY_TGZ:BOOL=ON -DCPACK_BINARY_DEB:BOOL=ON \ + -DCPACK_BINARY_IFW:BOOL=OFF -DCPACK_BINARY_NSIS:BOOL=OFF -DCPACK_BINARY_RPM:BOOL=OFF -DCPACK_BINARY_STGZ:BOOL=OFF \ + -DCPACK_BINARY_TBZ2:BOOL=OFF -DCPACK_BINARY_TXZ:BOOL=OFF -DCPACK_BINARY_TZ:BOOL=OFF \ + -DCMAKE_EXPORT_COMPILE_COMMANDS:BOOL=ON \ + ../OpenStudio +``` + +You can deactivate now if you want + +``` +# Unix +. ./deactivate_conanbuild.sh +# Windows +call deactivate_conanbuild.bat +``` + +# Full Example + +``` +git clone git@github.com/NREL/OpenStudio.git +cd OpenStudio +conan install . --output-folder=../OSApp-build-release --build=missing -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release +cmake --preset conan-release +cmake --build --preset conan-release +``` + +# Updating the Conan Lockfile + +If you want to update a dependency in the `conan.lock`, just delete the line, and use this: + + +```shell +conan install . --output-folder=../OSApp-build-release --build=missing \ + -c tools.cmake.cmaketoolchain:generator=Ninja -s compiler.cppstd=20 -s build_type=Release \ + --lockfile-partial --lockfile-out=conan.lock +``` diff --git a/CMake/FindRuby.cmake b/CMake/FindRuby.cmake deleted file mode 100644 index ee07f8345..000000000 --- a/CMake/FindRuby.cmake +++ /dev/null @@ -1,533 +0,0 @@ -# Distributed under the OSI-approved BSD 3-Clause License. See accompanying -# file Copyright.txt or https://cmake.org/licensing for details. - -#[=======================================================================[.rst: -FindRuby --------- - -Find Ruby - -This module finds if Ruby is installed and determines where the -include files and libraries are. Ruby 1.8 through 2.7 are -supported. - -The minimum required version of Ruby can be specified using the -standard syntax, e.g. - -.. code-block:: cmake - - find_package(Ruby 2.5.1 EXACT REQUIRED) - # OR - find_package(Ruby 2.4) - -It also determines what the name of the library is. - -Virtual environments such as RVM are handled as well, by passing -the argument ``Ruby_FIND_VIRTUALENV`` - -Result Variables -^^^^^^^^^^^^^^^^ - -This module will set the following variables in your project: - -``Ruby_FOUND`` - set to true if ruby was found successfully -``Ruby_EXECUTABLE`` - full path to the ruby binary -``Ruby_INCLUDE_DIRS`` - include dirs to be used when using the ruby library -``Ruby_LIBRARIES`` - .. versionadded:: 3.18 - libraries needed to use ruby from C. -``Ruby_VERSION`` - the version of ruby which was found, e.g. "1.8.7" -``Ruby_VERSION_MAJOR`` - Ruby major version. -``Ruby_VERSION_MINOR`` - Ruby minor version. -``Ruby_VERSION_PATCH`` - Ruby patch version. - -.. versionchanged:: 3.18 - Previous versions of CMake used the ``RUBY_`` prefix for all variables. - The following variables are provided for compatibility reasons, - don't use them in new code: - -``RUBY_EXECUTABLE`` - same as Ruby_EXECUTABLE. -``RUBY_INCLUDE_DIRS`` - same as Ruby_INCLUDE_DIRS. -``RUBY_INCLUDE_PATH`` - same as Ruby_INCLUDE_DIRS. -``RUBY_LIBRARY`` - same as Ruby_LIBRARY. -``RUBY_VERSION`` - same as Ruby_VERSION. -``RUBY_FOUND`` - same as Ruby_FOUND. - -Hints -^^^^^ - -.. versionadded:: 3.18 - -``Ruby_ROOT_DIR`` - Define the root directory of a Ruby installation. - -``Ruby_FIND_VIRTUALENV`` - This variable defines the handling of virtual environments managed by - ``rvm``. It is meaningful only when a virtual environment - is active (i.e. the ``rvm`` script has been evaluated or at least the - ``MY_RUBY_HOME`` environment variable is set). - The ``Ruby_FIND_VIRTUALENV`` variable can be set to empty or - one of the following: - - * ``FIRST``: The virtual environment is used before any other standard - paths to look-up for the interpreter. This is the default. - * ``ONLY``: Only the virtual environment is used to look-up for the - interpreter. - * ``STANDARD``: The virtual environment is not used to look-up for the - interpreter (assuming it isn't still in the PATH...) - -#]=======================================================================] - -# Backwards compatibility -# Define camel case versions of input variables -foreach(UPPER - RUBY_EXECUTABLE - RUBY_LIBRARY - RUBY_INCLUDE_DIR - RUBY_CONFIG_INCLUDE_DIR - ) - if (DEFINED ${UPPER}) - string(REPLACE "RUBY_" "Ruby_" Camel ${UPPER}) - if (NOT DEFINED ${Camel}) - set(${Camel} ${${UPPER}}) - endif() - endif() -endforeach() - -# Ruby_ARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"archdir"@:>@)'` -# Ruby_SITEARCHDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitearchdir"@:>@)'` -# Ruby_SITEDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"sitelibdir"@:>@)'` -# Ruby_LIBDIR=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"libdir"@:>@)'` -# Ruby_LIBRUBYARG=`$RUBY -r rbconfig -e 'printf("%s",Config::CONFIG@<:@"LIBRUBYARG_SHARED"@:>@)'` - -# uncomment the following line to get debug output for this file -# set(_Ruby_DEBUG_OUTPUT TRUE) - -# Determine the list of possible names of the ruby executable depending -# on which version of ruby is required -set(_Ruby_POSSIBLE_EXECUTABLE_NAMES ruby) - -# If not specified, allow everything as far back as 1.8.0 -if(NOT DEFINED Ruby_FIND_VERSION_MAJOR) - set(Ruby_FIND_VERSION "1.8.0") - set(Ruby_FIND_VERSION_MAJOR 1) - set(Ruby_FIND_VERSION_MINOR 8) - set(Ruby_FIND_VERSION_PATCH 0) -endif() - -if(_Ruby_DEBUG_OUTPUT) - message("Ruby_FIND_VERSION=${Ruby_FIND_VERSION}") - message("Ruby_FIND_VERSION_MAJOR=${Ruby_FIND_VERSION_MAJOR}") - message("Ruby_FIND_VERSION_MINOR=${Ruby_FIND_VERSION_MINOR}") - message("Ruby_FIND_VERSION_PATCH=${Ruby_FIND_VERSION_PATCH}") -endif() - -set(Ruby_FIND_VERSION_SHORT_NODOT "${Ruby_FIND_VERSION_MAJOR}${Ruby_FIND_VERSION_MINOR}") - -# Set name of possible executables, ignoring the minor -# Eg: -# 2.1.1 => from ruby27 to ruby21 included -# 2.1 => from ruby27 to ruby21 included -# 2 => from ruby26 to ruby20 included -# empty => from ruby27 to ruby18 included -if(NOT Ruby_FIND_VERSION_EXACT) - - foreach(_ruby_version RANGE 27 18 -1) - string(SUBSTRING "${_ruby_version}" 0 1 _ruby_major_version) - string(SUBSTRING "${_ruby_version}" 1 1 _ruby_minor_version) - - if(NOT "${_ruby_major_version}${_ruby_minor_version}" VERSION_LESS ${Ruby_FIND_VERSION_SHORT_NODOT}) - # Append both rubyX.Y and rubyXY (eg: ruby2.7 ruby27) - list(APPEND _Ruby_POSSIBLE_EXECUTABLE_NAMES ruby${_ruby_major_version}.${_ruby_minor_version} ruby${_ruby_major_version}${_ruby_minor_version}) - else() - break() - endif() - - endforeach() - - list(REMOVE_DUPLICATES _Ruby_POSSIBLE_EXECUTABLE_NAMES) -endif() - -# virtual environments handling (eg RVM) -if (DEFINED ENV{MY_RUBY_HOME}) - if(_Ruby_DEBUG_OUTPUT) - message("My ruby home is defined: $ENV{MY_RUBY_HOME}") - endif() - - if (DEFINED Ruby_FIND_VIRTUALENV) - if (NOT Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY|STANDARD)$") - message (AUTHOR_WARNING "FindRuby: ${Ruby_FIND_VIRTUALENV}: invalid value for 'Ruby_FIND_VIRTUALENV'. 'FIRST', 'ONLY' or 'STANDARD' expected. 'FIRST' will be used instead.") - set (_Ruby_FIND_VIRTUALENV "FIRST") - else() - set (_Ruby_FIND_VIRTUALENV ${Ruby_FIND_VIRTUALENV}) - endif() - else() - set (_Ruby_FIND_VIRTUALENV FIRST) - endif() -else() - if (DEFINED Ruby_FIND_VIRTUALENV) - message("Environment variable MY_RUBY_HOME isn't set, defaulting back to Ruby_FIND_VIRTUALENV=STANDARD") - endif() - set (_Ruby_FIND_VIRTUALENV STANDARD) -endif() - -if(_Ruby_DEBUG_OUTPUT) - message("_Ruby_POSSIBLE_EXECUTABLE_NAMES=${_Ruby_POSSIBLE_EXECUTABLE_NAMES}") - message("_Ruby_FIND_VIRTUALENV=${_Ruby_FIND_VIRTUALENV}") -endif() - -function (_RUBY_VALIDATE_INTERPRETER) - if (NOT Ruby_EXECUTABLE) - return() - endif() - - cmake_parse_arguments (PARSE_ARGV 0 _RVI "EXACT;CHECK_EXISTS" "" "") - if (_RVI_UNPARSED_ARGUMENTS) - set (expected_version ${_RVI_UNPARSED_ARGUMENTS}) - else() - unset (expected_version) - endif() - - if (_RVI_CHECK_EXISTS AND NOT EXISTS "${Ruby_EXECUTABLE}") - # interpreter does not exist anymore - set (_Ruby_Interpreter_REASON_FAILURE "Cannot find the interpreter \"${Ruby_EXECUTABLE}\"") - set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND") - return() - endif() - - # Check the version it returns - # executable found must have a specific version - execute_process (COMMAND "${Ruby_EXECUTABLE}" -e "puts RUBY_VERSION" - RESULT_VARIABLE result - OUTPUT_VARIABLE version - ERROR_QUIET - OUTPUT_STRIP_TRAILING_WHITESPACE) - if (result OR (_RVI_EXACT AND NOT version VERSION_EQUAL expected_version) OR (version VERSION_LESS expected_version)) - # interpreter not usable or has wrong major version - if (result) - set (_Ruby_Interpreter_REASON_FAILURE "Cannot use the interpreter \"${Ruby_EXECUTABLE}\"") - else() - set (_Ruby_Interpreter_REASON_FAILURE "Wrong major version for the interpreter \"${Ruby_EXECUTABLE}\"") - endif() - set_property (CACHE Ruby_EXECUTABLE PROPERTY VALUE "Ruby_EXECUTABLE-NOTFOUND") - return() - endif() - -endfunction() - -while(1) - # Virtual environments handling - if(_Ruby_FIND_VIRTUALENV MATCHES "^(FIRST|ONLY)$") - if(_Ruby_DEBUG_OUTPUT) - message("Inside Matches") - endif() - find_program (Ruby_EXECUTABLE - NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES} - NAMES_PER_DIR - PATHS ENV MY_RUBY_HOME - PATH_SUFFIXES bin Scripts - NO_CMAKE_PATH - NO_CMAKE_ENVIRONMENT_PATH - NO_SYSTEM_ENVIRONMENT_PATH - NO_CMAKE_SYSTEM_PATH) - - if(_Ruby_DEBUG_OUTPUT) - message("Ruby_EXECUTABLE=${Ruby_EXECUTABLE}") - endif() - - _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION}}) - if(Ruby_EXECUTABLE) - break() - endif() - if(NOT _Ruby_FIND_VIRTUALENV STREQUAL "ONLY") - break() - endif() - elseif(_Ruby_DEBUG_OUTPUT) - message("_Ruby_FIND_VIRTUALENV doesn't match: ${_Ruby_FIND_VIRTUALENV}") - endif() - - # try using standard paths - find_program (Ruby_EXECUTABLE - NAMES ${_Ruby_POSSIBLE_EXECUTABLE_NAMES} - NAMES_PER_DIR) - _RUBY_VALIDATE_INTERPRETER (${Ruby_FIND_VERSION}) - if (Ruby_EXECUTABLE) - break() - endif() - - break() -endwhile() - -if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) - function(_RUBY_CONFIG_VAR RBVAR OUTVAR) - execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print RbConfig::CONFIG['${RBVAR}']" - RESULT_VARIABLE _Ruby_SUCCESS - OUTPUT_VARIABLE _Ruby_OUTPUT - ERROR_QUIET) - if(_Ruby_SUCCESS OR _Ruby_OUTPUT STREQUAL "") - execute_process(COMMAND ${Ruby_EXECUTABLE} -r rbconfig -e "print Config::CONFIG['${RBVAR}']" - RESULT_VARIABLE _Ruby_SUCCESS - OUTPUT_VARIABLE _Ruby_OUTPUT - ERROR_QUIET) - endif() - set(${OUTVAR} "${_Ruby_OUTPUT}" PARENT_SCOPE) - endfunction() - - - # query the ruby version - _RUBY_CONFIG_VAR("MAJOR" Ruby_VERSION_MAJOR) - _RUBY_CONFIG_VAR("MINOR" Ruby_VERSION_MINOR) - _RUBY_CONFIG_VAR("TEENY" Ruby_VERSION_PATCH) - - # query the different directories - _RUBY_CONFIG_VAR("archdir" Ruby_ARCH_DIR) - _RUBY_CONFIG_VAR("arch" Ruby_ARCH) - _RUBY_CONFIG_VAR("rubyhdrdir" Ruby_HDR_DIR) - _RUBY_CONFIG_VAR("rubyarchhdrdir" Ruby_ARCHHDR_DIR) - _RUBY_CONFIG_VAR("libdir" Ruby_POSSIBLE_LIB_DIR) - _RUBY_CONFIG_VAR("rubylibdir" Ruby_RUBY_LIB_DIR) - - # site_ruby - _RUBY_CONFIG_VAR("sitearchdir" Ruby_SITEARCH_DIR) - _RUBY_CONFIG_VAR("sitelibdir" Ruby_SITELIB_DIR) - - # vendor_ruby available ? - execute_process(COMMAND ${Ruby_EXECUTABLE} -r vendor-specific -e "print 'true'" - OUTPUT_VARIABLE Ruby_HAS_VENDOR_RUBY ERROR_QUIET) - - if(Ruby_HAS_VENDOR_RUBY) - _RUBY_CONFIG_VAR("vendorlibdir" Ruby_VENDORLIB_DIR) - _RUBY_CONFIG_VAR("vendorarchdir" Ruby_VENDORARCH_DIR) - endif() - - # save the results in the cache so we don't have to run ruby the next time again - set(Ruby_VERSION_MAJOR ${Ruby_VERSION_MAJOR} CACHE PATH "The Ruby major version" FORCE) - set(Ruby_VERSION_MINOR ${Ruby_VERSION_MINOR} CACHE PATH "The Ruby minor version" FORCE) - set(Ruby_VERSION_PATCH ${Ruby_VERSION_PATCH} CACHE PATH "The Ruby patch version" FORCE) - set(Ruby_ARCH_DIR ${Ruby_ARCH_DIR} CACHE PATH "The Ruby arch dir" FORCE) - set(Ruby_HDR_DIR ${Ruby_HDR_DIR} CACHE PATH "The Ruby header dir (1.9+)" FORCE) - set(Ruby_ARCHHDR_DIR ${Ruby_ARCHHDR_DIR} CACHE PATH "The Ruby arch header dir (2.0+)" FORCE) - set(Ruby_POSSIBLE_LIB_DIR ${Ruby_POSSIBLE_LIB_DIR} CACHE PATH "The Ruby lib dir" FORCE) - set(Ruby_RUBY_LIB_DIR ${Ruby_RUBY_LIB_DIR} CACHE PATH "The Ruby ruby-lib dir" FORCE) - set(Ruby_SITEARCH_DIR ${Ruby_SITEARCH_DIR} CACHE PATH "The Ruby site arch dir" FORCE) - set(Ruby_SITELIB_DIR ${Ruby_SITELIB_DIR} CACHE PATH "The Ruby site lib dir" FORCE) - set(Ruby_HAS_VENDOR_RUBY ${Ruby_HAS_VENDOR_RUBY} CACHE BOOL "Vendor Ruby is available" FORCE) - set(Ruby_VENDORARCH_DIR ${Ruby_VENDORARCH_DIR} CACHE PATH "The Ruby vendor arch dir" FORCE) - set(Ruby_VENDORLIB_DIR ${Ruby_VENDORLIB_DIR} CACHE PATH "The Ruby vendor lib dir" FORCE) - - mark_as_advanced( - Ruby_ARCH_DIR - Ruby_ARCH - Ruby_HDR_DIR - Ruby_ARCHHDR_DIR - Ruby_POSSIBLE_LIB_DIR - Ruby_RUBY_LIB_DIR - Ruby_SITEARCH_DIR - Ruby_SITELIB_DIR - Ruby_HAS_VENDOR_RUBY - Ruby_VENDORARCH_DIR - Ruby_VENDORLIB_DIR - Ruby_VERSION_MAJOR - Ruby_VERSION_MINOR - Ruby_VERSION_PATCH - ) -endif() - -# In case Ruby_EXECUTABLE could not be executed (e.g. cross compiling) -# try to detect which version we found. This is not too good. -if(Ruby_EXECUTABLE AND NOT Ruby_VERSION_MAJOR) - # by default assume 1.8.0 - set(Ruby_VERSION_MAJOR 1) - set(Ruby_VERSION_MINOR 8) - set(Ruby_VERSION_PATCH 0) - # check whether we found 1.9.x - if(${Ruby_EXECUTABLE} MATCHES "ruby1\\.?9") - set(Ruby_VERSION_MAJOR 1) - set(Ruby_VERSION_MINOR 9) - endif() - # check whether we found 2.0.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?0") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 0) - endif() - # check whether we found 2.1.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?1") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 1) - endif() - # check whether we found 2.2.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?2") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 2) - endif() - # check whether we found 2.3.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?3") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 3) - endif() - # check whether we found 2.4.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?4") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 4) - endif() - # check whether we found 2.5.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?5") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 5) - endif() - # check whether we found 2.6.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?6") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 6) - endif() - # check whether we found 2.7.x - if(${Ruby_EXECUTABLE} MATCHES "ruby2\\.?7") - set(Ruby_VERSION_MAJOR 2) - set(Ruby_VERSION_MINOR 7) - endif() -endif() - -if(Ruby_VERSION_MAJOR) - set(Ruby_VERSION "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}.${Ruby_VERSION_PATCH}") - set(_Ruby_VERSION_SHORT "${Ruby_VERSION_MAJOR}.${Ruby_VERSION_MINOR}") - set(_Ruby_VERSION_SHORT_NODOT "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}") - set(_Ruby_NODOT_VERSION "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}${Ruby_VERSION_PATCH}") - set(_Ruby_NODOT_VERSION_ZERO_PATCH "${Ruby_VERSION_MAJOR}${Ruby_VERSION_MINOR}0") -endif() - -# FIXME: Currently we require both the interpreter and development components to be found -# in order to use either. See issue #20474. -find_path(Ruby_INCLUDE_DIR - NAMES ruby.h - HINTS - ${Ruby_HDR_DIR} - ${Ruby_ARCH_DIR} - /usr/lib/ruby/${_Ruby_VERSION_SHORT}/i586-linux-gnu/ -) - -set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIR}) - -# if ruby > 1.8 is required or if ruby > 1.8 was found, search for the config.h dir -if( Ruby_FIND_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_VERSION VERSION_GREATER_EQUAL "1.9" OR Ruby_HDR_DIR) - find_path(Ruby_CONFIG_INCLUDE_DIR - NAMES ruby/config.h config.h - HINTS - ${Ruby_HDR_DIR}/${Ruby_ARCH} - ${Ruby_ARCH_DIR} - ${Ruby_ARCHHDR_DIR} - ) - - set(Ruby_INCLUDE_DIRS ${Ruby_INCLUDE_DIRS} ${Ruby_CONFIG_INCLUDE_DIR} ) -endif() - - -# Determine the list of possible names for the ruby library -set(_Ruby_POSSIBLE_LIB_NAMES ruby ruby-static ruby${_Ruby_VERSION_SHORT} ruby${_Ruby_VERSION_SHORT_NODOT} ruby-${_Ruby_VERSION_SHORT} ruby-${Ruby_VERSION}) - -if(WIN32) - set(_Ruby_POSSIBLE_MSVC_RUNTIMES "msvcrt;vcruntime140;vcruntime140_1") - if(MSVC_TOOLSET_VERSION) - list(APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr${MSVC_TOOLSET_VERSION}") - else() - list(APPEND _Ruby_POSSIBLE_MSVC_RUNTIMES "msvcr") - endif() - - set(_Ruby_POSSIBLE_VERSION_SUFFICES "${_Ruby_NODOT_VERSION};${_Ruby_NODOT_VERSION_ZERO_PATCH}") - - set(_Ruby_ARCH_PREFIX "") - if(CMAKE_SIZEOF_VOID_P EQUAL 8) - set(_Ruby_ARCH_PREFIX "x64-") - endif() - - foreach(_Ruby_MSVC_RUNTIME ${_Ruby_POSSIBLE_MSVC_RUNTIMES}) - foreach(_Ruby_VERSION_SUFFIX ${_Ruby_POSSIBLE_VERSION_SUFFICES}) - list(APPEND _Ruby_POSSIBLE_LIB_NAMES - "${_Ruby_ARCH_PREFIX}${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}" - "${_Ruby_ARCH_PREFIX}${_Ruby_MSVC_RUNTIME}-ruby${_Ruby_VERSION_SUFFIX}-static") - endforeach() - endforeach() -endif() - -find_library(Ruby_LIBRARY NAMES ${_Ruby_POSSIBLE_LIB_NAMES} HINTS ${Ruby_POSSIBLE_LIB_DIR} ) - -set(_Ruby_REQUIRED_VARS Ruby_EXECUTABLE Ruby_INCLUDE_DIR Ruby_LIBRARY) -if(_Ruby_VERSION_SHORT_NODOT GREATER 18) - list(APPEND _Ruby_REQUIRED_VARS Ruby_CONFIG_INCLUDE_DIR) -endif() - -if(_Ruby_DEBUG_OUTPUT) - message(STATUS "--------FindRuby.cmake debug------------") - message(STATUS "_Ruby_POSSIBLE_EXECUTABLE_NAMES: ${_Ruby_POSSIBLE_EXECUTABLE_NAMES}") - message(STATUS "_Ruby_POSSIBLE_LIB_NAMES: ${_Ruby_POSSIBLE_LIB_NAMES}") - message(STATUS "Ruby_ARCH_DIR: ${Ruby_ARCH_DIR}") - message(STATUS "Ruby_HDR_DIR: ${Ruby_HDR_DIR}") - message(STATUS "Ruby_POSSIBLE_LIB_DIR: ${Ruby_POSSIBLE_LIB_DIR}") - message(STATUS "Found Ruby_VERSION: \"${Ruby_VERSION}\" , short: \"${_Ruby_VERSION_SHORT}\", nodot: \"${_Ruby_VERSION_SHORT_NODOT}\"") - message(STATUS "_Ruby_REQUIRED_VARS: ${_Ruby_REQUIRED_VARS}") - message(STATUS "Ruby_EXECUTABLE: ${Ruby_EXECUTABLE}") - message(STATUS "Ruby_LIBRARY: ${Ruby_LIBRARY}") - message(STATUS "Ruby_INCLUDE_DIR: ${Ruby_INCLUDE_DIR}") - message(STATUS "Ruby_CONFIG_INCLUDE_DIR: ${Ruby_CONFIG_INCLUDE_DIR}") - message(STATUS "--------------------") -endif() - -include(${CMAKE_CURRENT_LIST_DIR}/FindPackageHandleStandardArgs.cmake) -FIND_PACKAGE_HANDLE_STANDARD_ARGS(Ruby REQUIRED_VARS ${_Ruby_REQUIRED_VARS} - VERSION_VAR Ruby_VERSION ) - -if(Ruby_FOUND) - set(Ruby_LIBRARIES ${Ruby_LIBRARY}) -endif() - -mark_as_advanced( - Ruby_EXECUTABLE - Ruby_LIBRARY - Ruby_INCLUDE_DIR - Ruby_CONFIG_INCLUDE_DIR - ) - -# Set some variables for compatibility with previous version of this file (no need to provide a CamelCase version of that...) -set(RUBY_POSSIBLE_LIB_PATH ${Ruby_POSSIBLE_LIB_DIR}) -set(RUBY_RUBY_LIB_PATH ${Ruby_RUBY_LIB_DIR}) -set(RUBY_INCLUDE_PATH ${Ruby_INCLUDE_DIRS}) - -# Backwards compatibility -# Define upper case versions of output variables -foreach(Camel - Ruby_EXECUTABLE - Ruby_INCLUDE_DIRS - Ruby_LIBRARY - Ruby_VERSION - Ruby_VERSION_MAJOR - Ruby_VERSION_MINOR - Ruby_VERSION_PATCH - - Ruby_ARCH_DIR - Ruby_ARCH - Ruby_HDR_DIR - Ruby_ARCHHDR_DIR - Ruby_POSSIBLE_LIB_DIR - Ruby_RUBY_LIB_DIR - Ruby_SITEARCH_DIR - Ruby_SITELIB_DIR - Ruby_HAS_VENDOR_RUBY - Ruby_VENDORARCH_DIR - Ruby_VENDORLIB_DIR - - ) - string(TOUPPER ${Camel} UPPER) - set(${UPPER} ${${Camel}}) -endforeach() diff --git a/CMake/TargetArch.cmake b/CMake/TargetArch.cmake deleted file mode 100644 index 771f3d088..000000000 --- a/CMake/TargetArch.cmake +++ /dev/null @@ -1,146 +0,0 @@ -# Based on the Qt 5 processor detection code, so should be very accurate -# https://qt.gitorious.org/qt/qtbase/blobs/master/src/corelib/global/qprocessordetection.h -# Currently handles arm (v5, v6, v7), x86 (32/64), ia64, and ppc (32/64) - -# Regarding POWER/PowerPC, just as is noted in the Qt source, -# "There are many more known variants/revisions that we do not handle/detect." - -set(archdetect_c_code - " -#if defined(__arm__) || defined(__TARGET_ARCH_ARM) || defined(_M_ARM) || defined(_M_ARM64) || defined(__aarch64__) || defined(__ARM64__) - #if defined(__ARM64_ARCH_8__) \\ - || defined(__aarch64__) \\ - || defined(__ARMv8__) \\ - || defined(__ARMv8_A__) \\ - || defined(_M_ARM64) - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 8) - #error cmake_ARCH arm64 - #elif defined(__ARM_ARCH_7__) \\ - || defined(__ARM_ARCH_7A__) \\ - || defined(__ARM_ARCH_7R__) \\ - || defined(__ARM_ARCH_7M__) \\ - || defined(__ARM_ARCH_7S__) \\ - || defined(_ARM_ARCH_7) \\ - || defined(__CORE_CORTEXA__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 7) - #error cmake_ARCH armv7 - #elif defined(__ARM_ARCH_6__) \\ - || defined(__ARM_ARCH_6J__) \\ - || defined(__ARM_ARCH_6T2__) \\ - || defined(__ARM_ARCH_6Z__) \\ - || defined(__ARM_ARCH_6K__) \\ - || defined(__ARM_ARCH_6ZK__) \\ - || defined(__ARM_ARCH_6M__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 6) - #error cmake_ARCH armv6 - #elif defined(__ARM_ARCH_5TEJ__) \\ - || (defined(__TARGET_ARCH_ARM) && __TARGET_ARCH_ARM-0 >= 5) - #error cmake_ARCH armv5 - #else - #error cmake_ARCH arm - #endif -#elif defined(__i386) || defined(__i386__) || defined(_M_IX86) - #error cmake_ARCH i386 -#elif defined(__x86_64) || defined(__x86_64__) || defined(__amd64) || defined(_M_X64) - #error cmake_ARCH x86_64 -#elif defined(__ia64) || defined(__ia64__) || defined(_M_IA64) - #error cmake_ARCH ia64 -#elif defined(__ppc__) || defined(__ppc) || defined(__powerpc__) \\ - || defined(_ARCH_COM) || defined(_ARCH_PWR) || defined(_ARCH_PPC) \\ - || defined(_M_MPPC) || defined(_M_PPC) - #if defined(__ppc64__) || defined(__powerpc64__) || defined(__64BIT__) - #error cmake_ARCH ppc64 - #else - #error cmake_ARCH ppc - #endif -#endif - -#error cmake_ARCH unknown -") - -# Set ppc_support to TRUE before including this file or ppc and ppc64 -# will be treated as invalid architectures since they are no longer supported by Apple - -function(target_architecture output_var) - if(APPLE AND CMAKE_OSX_ARCHITECTURES) - # On OS X we use CMAKE_OSX_ARCHITECTURES *if* it was set - # First let's normalize the order of the values - - # Note that it's not possible to compile PowerPC applications if you are using - # the OS X SDK version 10.6 or later - you'll need 10.4/10.5 for that, so we - # disable it by default - # See this page for more information: - # http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4 - - # Architecture defaults to i386 or ppc on OS X 10.5 and earlier, depending on the CPU type detected at runtime. - # On OS X 10.6+ the default is x86_64 if the CPU supports it, i386 otherwise. - - foreach(osx_arch ${CMAKE_OSX_ARCHITECTURES}) - if("${osx_arch}" STREQUAL "ppc" AND ppc_support) - set(osx_arch_ppc TRUE) - elseif("${osx_arch}" STREQUAL "i386") - set(osx_arch_i386 TRUE) - elseif("${osx_arch}" STREQUAL "x86_64") - set(osx_arch_x86_64 TRUE) - elseif("${osx_arch}" STREQUAL "ppc64" AND ppc_support) - set(osx_arch_ppc64 TRUE) - elseif("${osx_arch}" STREQUAL "arm64") - set(osx_arch_arm64 TRUE) - else() - message(FATAL_ERROR "Invalid OS X arch name: ${osx_arch}") - endif() - endforeach() - - # Now add all the architectures in our normalized order - if(osx_arch_ppc) - list(APPEND ARCH ppc) - endif() - - if(osx_arch_i386) - list(APPEND ARCH i386) - endif() - - if(osx_arch_x86_64) - list(APPEND ARCH x86_64) - endif() - - if(osx_arch_ppc64) - list(APPEND ARCH ppc64) - endif() - - if(osx_arch_arm64) - list(APPEND ARCH arm64) - endif() - - else() - file(WRITE "${PROJECT_BINARY_DIR}/arch.c" "${archdetect_c_code}") - - enable_language(C) - - # Detect the architecture in a rather creative way... - # This compiles a small C program which is a series of ifdefs that selects a - # particular #error preprocessor directive whose message string contains the - # target architecture. The program will always fail to compile (both because - # file is not a valid C program, and obviously because of the presence of the - # #error preprocessor directives... but by exploiting the preprocessor in this - # way, we can detect the correct target architecture even when cross-compiling, - # since the program itself never needs to be run (only the compiler/preprocessor) - try_run(run_result_unused compile_result_unused "${PROJECT_BINARY_DIR}" "${PROJECT_BINARY_DIR}/arch.c" COMPILE_OUTPUT_VARIABLE ARCH - CMAKE_FLAGS CMAKE_OSX_ARCHITECTURES=${CMAKE_OSX_ARCHITECTURES}) - - # Parse the architecture name from the compiler output - string(REGEX MATCH "cmake_ARCH ([a-zA-Z0-9_]+)" ARCH "${ARCH}") - - # Get rid of the value marker leaving just the architecture name - string(REPLACE "cmake_ARCH " "" ARCH "${ARCH}") - - # If we are compiling with an unknown architecture this variable should - # already be set to "unknown" but in the case that it's empty (i.e. due - # to a typo in the code), then set it to unknown - if(NOT ARCH) - set(ARCH unknown) - endif() - endif() - - set(${output_var} "${ARCH}" PARENT_SCOPE) -endfunction() diff --git a/CMakeLists.txt b/CMakeLists.txt index db826c12b..4f3dc8f1f 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -80,22 +80,31 @@ include(FindOpenStudioSDK.cmake) # C O N A N # ############################################################################### -# Note JM 2019-04-24: Another option is to globally set "print_run_commands = True" in ~/.conan/conan.conf -option(CONAN_PRINT_RUN_COMMANDS "Log every conan self.run command" OFF) -mark_as_advanced(CONAN_PRINT_RUN_COMMANDS) -if(CONAN_PRINT_RUN_COMMANDS) - set(ENV{CONAN_PRINT_RUN_COMMANDS} "1") - message("Setting CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}") -else() - unset(ENV{CONAN_PRINT_RUN_COMMANDS}) - message("CONAN_PRINT_RUN_COMMANDS: $ENV{CONAN_PRINT_RUN_COMMANDS}") +find_package(Ruby) +message("Ruby_INCLUDE_DIRS=${Ruby_INCLUDE_DIRS}") +find_package(pugixml) +find_package(LibXslt) +find_package(libxml2) +find_package(jsoncpp) +find_package(fmt) +find_package(SQLite3) +find_package(cpprestsdk) +find_package(websocketpp) +find_package(Boost) +find_package(geographiclib) +find_package(SWIG 4.1.1 EXACT REQUIRED CONFIG) +message("SWIG_EXECUTABLE=${SWIG_EXECUTABLE}") +message("SWIG_DIR=${SWIG_DIR}") +find_package(TinyGLTF) +find_package(minizip) +find_package(OpenSSL) +find_package(ZLIB) +if(BUILD_TESTING) + find_package(GTest) +endif() +if(BUILD_BENCHMARK) + find_package(benchmark) endif() - -# Attempt to run, it'll do the right thing if the calling cmake script already ran it -set(CONAN_INSTALL_FILE "${PROJECT_SOURCE_DIR}/ConanInstall.cmake") -include("${CONAN_INSTALL_FILE}") - -get_target_property(RUBY_INCLUDE_DIRS CONAN_PKG::openstudio_ruby INTERFACE_INCLUDE_DIRECTORIES) # A macro to find a conan related value especially when using multi-config builds (MSVC) # But it also works with single-config builds @@ -498,12 +507,6 @@ if(UNIX) mark_as_advanced(CMAKE_THREAD_LIBS) endif() -# Swig -FindValue(CONAN_SWIG_ROOT) -set(SWIG_EXECUTABLE "${CURRENT_CONAN_SWIG_ROOT}/bin/swig") -# The conan-provided binary has a built-in swiglib (`swig -swiglib`) that points to the build box on which it was built, which is problematic for us. -set(SWIG_LIB "${CURRENT_CONAN_SWIG_ROOT}/bin/swiglib") - # Qt # e.g. QT_INSTALL_DIR = C:/Qt/6.6.3/msvc2019_64 set(QT_INSTALL_DIR "" CACHE PATH "Path to Qt Install") @@ -788,11 +791,8 @@ set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "OpenStudioApplication ${OpenStudioApplica # The actual package file name on disk if(APPLE) - include(CMake/TargetArch.cmake) - target_architecture(TARGET_ARCH) - # eg OpenStudioApplication-1.2.0-alpha+394bbe9f8d-macOS-10.15-x86_64 (future: OpenStudioApplication-1.2.0-alpha+394bbe9f8d-macOS-11.2-arm64) - set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENSTUDIOAPPLICATION_LONG_VERSION}-macOS${OSX_VERSION_MAJOR_MINOR}-${TARGET_ARCH}") + set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENSTUDIOAPPLICATION_LONG_VERSION}-macOS${OSX_VERSION_MAJOR_MINOR}-${ARCH}") elseif(UNIX) # eg: OpenStudioApplication-1.2.0-alpha+394bbe9f8d-Ubuntu18.04 set(CPACK_PACKAGE_FILE_NAME "${CMAKE_PROJECT_NAME}-${OPENSTUDIOAPPLICATION_LONG_VERSION}-${LSB_RELEASE_ID_SHORT}${LSB_RELEASE_VERSION_SHORT}") diff --git a/ConanInstall.cmake b/ConanInstall.cmake deleted file mode 100644 index a65cb0c7c..000000000 --- a/ConanInstall.cmake +++ /dev/null @@ -1,223 +0,0 @@ -# This file lists and installs the Conan packages needed - -# NOTE: DO NOT DO `set(CONAN_OPTIONS "")` since some higher level stuff may be added via OpenStudioApplication (we were toying on adding CONAN_QT at some point) - -if(NOT CONAN_OPENSTUDIO_ALREADY_RUN) - - set(CMAKE_CONAN_EXPECTED_HASH - 5cdb3042632da3efff558924eecefd580a0e786863a857ca097c3d1d43df5dcd) - set(CMAKE_CONAN_VERSION "0.18.1") - - if(EXISTS "${CMAKE_BINARY_DIR}/conan.cmake") - file(SHA256 "${CMAKE_BINARY_DIR}/conan.cmake" CMAKE_CONAN_HASH) - elseif(NOT EXISTS "${CMAKE_BINARY_DIR}/conan.cmake" - OR NOT "${CMAKE_CONAN_HASH}" MATCHES "${CMAKE_CONAN_EXPECTED_HASH}") - # Put it in CMAKE_BINARY_DIR so we don't end up with two when building OpenStudioApplication - message( - STATUS - "openstudio: Downloading conan.cmake ${CMAKE_CONAN_VERSION} from https://github.com/conan-io/cmake-conan" - ) - file( - DOWNLOAD - "https://raw.githubusercontent.com/conan-io/cmake-conan/${CMAKE_CONAN_VERSION}/conan.cmake" - "${CMAKE_BINARY_DIR}/conan.cmake" - EXPECTED_HASH SHA256=${CMAKE_CONAN_EXPECTED_HASH} - # TLS_VERIFY ON # TODO: 2023-10-27 - Started failing on Github Actions' Windows runner - ) - else() - message(STATUS "openstudio: using existing conan.cmake") - endif() - - include(${CMAKE_BINARY_DIR}/conan.cmake) - - conan_check(VERSION 1.53.0 REQUIRED) - - message(STATUS "openstudio: RUNNING CONAN") - - conan_add_remote(NAME nrel INDEX 0 - URL https://conan.openstudio.net/artifactory/api/conan/openstudio) - - # Track NREL/stable in general, on a feature branch this could be temporarily switched to NREL/testing - # TODO: temp, revert to stable soon - set(CONAN_RUBY "openstudio_ruby/2.7.2@nrel/testing#d66e3b66568b13acf3b16d866bec68d0") - - # TODO: temp, see issue #689 . gmp revision on NREL has sources to gmplib.org which banned GHA IP range, so pick a newer conan-center-index revision in the meantime that uses GCC's FTP. - if(WIN32) - set(CONAN_GMP "") - else() - set(CONAN_GMP "gmp/6.2.1#560eab30a8f52beae2cef5ff26cdd61c") - endif() - - # 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( - COMMAND ${CONAN_CMD} config get general.revisions_enabled - OUTPUT_VARIABLE CONAN_REV_STATUS - ERROR_VARIABLE CONAN_REV_STATUS - OUTPUT_STRIP_TRAILING_WHITESPACE) - - message( - STATUS "Conan: config get general.revisions_enabled=${CONAN_REV_STATUS}") - if(NOT "${CONAN_REV_STATUS}" STREQUAL "True") - message( - AUTHOR_WARNING - "Conan: Force enabling revisions (conan config set general.revisions_enabled=True)" - ) - execute_process(COMMAND ${CONAN_CMD} config set - general.revisions_enabled=True) - endif() - - # TODO: list(APPEND CONAN_OPTIONS "fmt:header_only=True") - - if(APPLE) - # #4120 - global is the 'default' visibility in gcc/clang - list(APPEND CONAN_OPTIONS "boost:visibility=global") - endif() - - # You do want to rebuild packages if there's a newer recipe in the remote (which applies mostly to our own openstudio_ruby where we don't - # bump the actual package version when we make changes) than the binaries were built with - # 'outdated' also acts like 'missing': if no binary, will build them. - # list(APPEND CONAN_BUILD "outdated") - list(APPEND CONAN_BUILD "missing") - - if(BUILD_TESTING) - set(CONAN_GTEST "gtest/1.11.0#8aca975046f1b60c660ee9d066764d69") - else() - set(CONAN_GTEST "") - endif() - - - # Build ALL dependencies to avoid problems with the way too old CentOS GLIBC (same on Ubuntu 18.04) - # Please read: `OpenStudio/developer/conan/binary_incompatility_glibc.md` - 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") - endif() - - # msys2/cci.latest is not supported on win32. We don't expect to run it on something else than an x86_64 anyways - if(CMAKE_SIZEOF_VOID_P EQUAL 4) # 32 bit - set(CONAN_FORCE_SETTINGS_BUILD SETTINGS_BUILD arch=x86_64) - message(AUTHOR_WARNING "Forcing --settings:build arch=x86_64") - if(NOT WIN32) - message(AUTHOR_WARNING "You are trying to build on x86 on a non-windows, this is completely untested and unsupported") - endif() - endif() - - set(CONAN_UPDATE "UPDATE") - - if(CMAKE_CONFIGURATION_TYPES AND NOT CMAKE_BUILD_TYPE) - set(CONAN_CMAKE_MULTI ON) - if (NOT CONAN_CONFIGURATION_TYPES) - # Cache it, and let user change it (if they want to pull RelWithDebInfo for eg) - set(CONAN_CONFIGURATION_TYPES "Release;Debug" CACHE STRING "List of configurations for which you want to fetch conan packages") - mark_as_advanced(CONAN_CONFIGURATION_TYPES) - endif() - message(STATUS "Conan: Using cmake_multi generator") - set(CONAN_GENERATOR "cmake_multi") - else() - message(STATUS "Conan: Using cmake generator") - set(CONAN_CMAKE_MULTI OFF) - set(CONAN_GENERATOR "cmake") - if (NOT CONAN_CONFIGURATION_TYPES) - set(CONAN_CONFIGURATION_TYPES ${CMAKE_BUILD_TYPE}) - endif() - endif() - - if( APPLE AND ${CMAKE_HOST_SYSTEM_PROCESSOR} STREQUAL "x86_64" ) - # use newer recipe which updated the mirror urls, for some reason this fails on other platforms - # https://github.com/conan-io/conan-center-index/pull/13435 - # https://conan.io/center/recipes/openssl?version=1.1.1o - set(CONAN_OPENSSL "openssl/1.1.1o#4405b3b0a045933a2065e194965b38c1") - else() - # align on the same as our conan-openstudio-ruby - set(CONAN_OPENSSL "openssl/1.1.1o#213dbdeb846a4b40b4dec36cf2e673d7") - endif() - - message(STATUS "Conan: conan_cmake_configure") - # This will create the conanfile.txt - conan_cmake_configure( - REQUIRES - ${CONAN_READLINE} - ${CONAN_QT} - ${CONAN_GMP} - ${CONAN_RUBY} - ${CONAN_OPENSSL} - "boost/1.79.0#f664bfe40e2245fa9baf1c742591d582" - "pugixml/1.12.1#5a39f82651eba3e7d6197903a3202e21" - "libxml2/2.9.14#fc433aeebfe525657d73334c61f96944" - "libxslt/1.1.34#9085031f5b9b2bb328ad615cd1bf1282" - "jsoncpp/1.9.5#536d080aa154e5853332339bf576747c" - "minizip/1.2.12#0b5296887a2558500d0323c6c94c8d02" # This depends on zlib, and basically patches it - "zlib/1.2.12#3b9e037ae1c615d045a06c67d88491ae" # Also needed, so we can find zlib.h and co (+ pinning exactly is good) - "fmt/9.1.0#811e918ca4b4e0b9ddd6d5a2883efa82" - "sqlite3/3.38.5#010911927ce1889b5cf824f45e7cd3d2" - "cpprestsdk/2.10.18#df2f6ac88e47cadd9c9e8e0971e00d89" - "websocketpp/0.8.2#3fd704c4c5388d9c08b11af86f79f616" - "geographiclib/1.52#76536a9315a003ef3511919310b2fe37" - "swig/4.1.0#f4419c5ab88f877272cbaa36dd0237ff" - "tinygltf/2.5.0#c8b2aca9505e86312bb42aa0e1c639ec" - ${CONAN_GTEST} - ${CONAN_BENCHMARK} - # Override to avoid dependency mismatches - #"bzip2/1.0.8#d4a5c7144832d75fc3f349c5346160b0" - #"libyaml/0.2.5#9e234874df88c3ba7249f6d1368fceaf" - GENERATORS ${CONAN_GENERATOR} - ) - - foreach(build_type ${CONAN_CONFIGURATION_TYPES}) - conan_cmake_autodetect(settings BUILD_TYPE ${build_type}) - message(STATUS "Conan: Autodetected settings for build type ${build_type}: ${settings}") - - # Avoid polluting with cppstd which prevents downloading some existing binary packages (like boost) - # Former deprecated conan_cmake_run was NOT adding compiler.cppstd - foreach(ARG ${settings}) - if(${ARG} MATCHES "compiler.cppstd=(.*)") - message("Removing ${ARG}") - list(REMOVE_ITEM settings ${ARG}) - endif() - endforeach() - - conan_cmake_install(PATH_OR_REFERENCE . - BUILD ${CONAN_BUILD} - OPTIONS ${CONAN_OPTIONS} - SETTINGS ${settings} - ${CONAN_FORCE_SETTINGS_BUILD} - ${CONAN_UPDATE} - ) - endforeach() - - # Loads the conanbuildinfo.cmake / conanbuildinfo_multi.cmake - conan_load_buildinfo() - # conan_basic_setup in the conanbuildinfo.cmake. TARGETS => set cmake targets, NO_OUTPUT_DIRS => Don't modify the BIN / LIB folders etc - conan_basic_setup(TARGETS NO_OUTPUT_DIRS) # TODO add KEEP_RPATHS ? - - set(CONAN_OPENSTUDIO_ALREADY_RUN TRUE) - - #message("CONAN_TARGETS = ${CONAN_TARGETS}") - message(STATUS "openstudio: DONE RUNNING CONAN") - -else() - - message(STATUS "openstudio: CONAN RUN BY CALLING SCRIPT") - -endif() diff --git a/FindOpenStudioSDK.cmake b/FindOpenStudioSDK.cmake index f95000deb..3065279b0 100644 --- a/FindOpenStudioSDK.cmake +++ b/FindOpenStudioSDK.cmake @@ -1,12 +1,12 @@ set(OPENSTUDIO_VERSION_MAJOR 3) -set(OPENSTUDIO_VERSION_MINOR 7) +set(OPENSTUDIO_VERSION_MINOR 8) set(OPENSTUDIO_VERSION_PATCH 0) set(OPENSTUDIO_VERSION "${OPENSTUDIO_VERSION_MAJOR}.${OPENSTUDIO_VERSION_MINOR}.${OPENSTUDIO_VERSION_PATCH}") #If this is an official release, leave this "", otherwise put for eg '-rc1' -set(OPENSTUDIO_VERSION_PRERELEASE "") +set(OPENSTUDIO_VERSION_PRERELEASE "-rc2") # Enter SHA, always, eg "+79857912c4" -set(OPENSTUDIO_VERSION_SHA "+d5269793f1") +set(OPENSTUDIO_VERSION_SHA "+af997f4fef") # Paths where the cmake-downloaded archives will be put set(OPENSTUDIO_ARCHIVE_DIR "${PROJECT_BINARY_DIR}/OpenStudio-${OPENSTUDIO_VERSION}") @@ -17,27 +17,27 @@ set(OPENSTUDIO_EXT "tar.gz") if(APPLE) set(OPENSTUDIO_PLATFORM "Darwin-${ARCH}") if(ARCH MATCHES "arm64") - set(OPENSTUDIO_EXPECTED_HASH 62d4fffc8f432d11db3bcc09f2861cfb) + set(OPENSTUDIO_EXPECTED_HASH 6a68bd93010d3fd5e7236913af956a76) else() - set(OPENSTUDIO_EXPECTED_HASH a4585ef0a3523168f8975ecd1cff1d12) + set(OPENSTUDIO_EXPECTED_HASH bb5e18b91537125689590038177c85a4) endif() elseif(UNIX) set(OPENSTUDIO_PLATFORM "${LSB_RELEASE_ID_SHORT}-${LSB_RELEASE_VERSION_SHORT}-${ARCH}") if(LSB_RELEASE_VERSION_SHORT MATCHES "22.04") if (ARCH MATCHES "arm64") - set(OPENSTUDIO_EXPECTED_HASH d98b3d3d133a7c5bc1b9581553d23811) + set(OPENSTUDIO_EXPECTED_HASH 57b2a8e706999a6eb1acbfbacf13241a) else() - set(OPENSTUDIO_EXPECTED_HASH 1e48f36417d3d118d6a10f1a7d61f46e) + set(OPENSTUDIO_EXPECTED_HASH 6b81e79fe69d0860d94922967b881855) endif() elseif(LSB_RELEASE_VERSION_SHORT MATCHES "20.04") - set(OPENSTUDIO_EXPECTED_HASH 5c006e5e66e5e859206a63626ea2966f) + set(OPENSTUDIO_EXPECTED_HASH 171510ee1a23d0542d0f71a9388d3bc3) else() message(FATAL_ERROR "OpenStudio SDK no longer provides packages for Ubuntu 18.04") endif() elseif(WIN32) - set(OPENSTUDIO_EXPECTED_HASH f192860357fdbffb5705942a991b072b) + set(OPENSTUDIO_EXPECTED_HASH 9230fddeb444a2792e575278c97c4335) set(OPENSTUDIO_PLATFORM "Windows") endif() @@ -121,8 +121,8 @@ else() INACTIVITY_TIMEOUT 900 # 15-min timeout STATUS DOWNLOAD_STATUS ) - list(GET DOWNLOAD_STATUS 0 DOWNLOAD_STATUS_CODE) - list(GET DOWNLOAD_STATUS 1 DOWNLOAD_ERROR_MSG) + list(GET DOWNLOAD_STATUS 0 DOWNLOAD_STATUS_CODE) + list(GET DOWNLOAD_STATUS 1 DOWNLOAD_ERROR_MSG) # If download didn't work if (DOWNLOAD_STATUS_CODE) diff --git a/ProjectMacros.cmake b/ProjectMacros.cmake index a478fc32b..6dbdc60d5 100644 --- a/ProjectMacros.cmake +++ b/ProjectMacros.cmake @@ -140,7 +140,7 @@ macro(CREATE_TEST_TARGETS BASE_NAME SRC DEPENDENCIES) endif() target_link_libraries(${BASE_NAME}_tests - CONAN_PKG::gtest + gtest::gtest ${ALL_DEPENDENCIES} ) @@ -336,7 +336,7 @@ macro(MAKE_SWIG_TARGET_OSAPP NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PA add_custom_command( OUTPUT "${SWIG_WRAPPER}" - COMMAND ${CMAKE_COMMAND} -E env SWIG_LIB="${SWIG_LIB}" + COMMAND ${CMAKE_COMMAND} -E env SWIG_DIR="${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-ruby" "-c++" "-fvirtual" ${swig_include_string} @@ -363,8 +363,6 @@ macro(MAKE_SWIG_TARGET_OSAPP NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PA ${SWIG_WRAPPER} ) - target_include_directories(${swig_target} SYSTEM PRIVATE ${RUBY_INCLUDE_DIRS}) - AddPCH(${swig_target}) # run rdoc @@ -419,7 +417,8 @@ macro(MAKE_SWIG_TARGET_OSAPP NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PA set_target_properties(${swig_target} PROPERTIES LIBRARY_OUTPUT_DIRECTORY "${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ruby/") set_target_properties(${swig_target} PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/ruby/") target_link_libraries(${swig_target} ${PARENT_TARGET}) - target_include_directories(${swig_target} SYSTEM PRIVATE ${RUBY_INCLUDE_DIRS}) + target_include_directories(${swig_target} SYSTEM PRIVATE ${Ruby_INCLUDE_DIRS}) + target_compile_definitions(${swig_target} PRIVATE SHARED_OS_LIBS PUBLIC -DRUBY_DONT_SUBST) add_dependencies(${swig_target} ${PARENT_TARGET}) # QT-Separation-Move @@ -556,7 +555,7 @@ macro(MAKE_SWIG_TARGET_OSAPP NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PA add_custom_command( OUTPUT "${SWIG_WRAPPER_FULL_PATH}" - COMMAND ${CMAKE_COMMAND} -E env SWIG_LIB="${SWIG_LIB}" + COMMAND ${CMAKE_COMMAND} -E env SWIG_DIR="${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-python" ${SWIG_PYTHON_3_FLAG} "-c++" ${PYTHON_AUTODOC} -outdir ${PYTHON_GENERATED_SRC_DIR} "-I${PROJECT_SOURCE_DIR}/src" "-I${PROJECT_BINARY_DIR}/src" @@ -711,7 +710,7 @@ macro(MAKE_SWIG_TARGET_OSAPP NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PA OUTPUT ${SWIG_WRAPPER_FULL_PATH} COMMAND "${CMAKE_COMMAND}" -E remove_directory "${CSHARP_GENERATED_SRC_DIR}" COMMAND "${CMAKE_COMMAND}" -E make_directory "${CSHARP_GENERATED_SRC_DIR}" - COMMAND ${CMAKE_COMMAND} -E env SWIG_LIB="${SWIG_LIB}" + COMMAND ${CMAKE_COMMAND} -E env SWIG_DIR="${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-csharp" "-c++" -namespace ${NAMESPACE} ${CSHARP_AUTODOC} -outdir "${CSHARP_GENERATED_SRC_DIR}" "-I${PROJECT_SOURCE_DIR}/src" "-I${PROJECT_BINARY_DIR}/src" @@ -805,7 +804,7 @@ macro(MAKE_SWIG_TARGET_OSAPP NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PA OUTPUT ${SWIG_WRAPPER} COMMAND "${CMAKE_COMMAND}" -E remove_directory "${JAVA_GENERATED_SRC_DIR}" COMMAND "${CMAKE_COMMAND}" -E make_directory "${JAVA_GENERATED_SRC_DIR}" - COMMAND ${CMAKE_COMMAND} -E env SWIG_LIB="${SWIG_LIB}" + COMMAND ${CMAKE_COMMAND} -E env SWIG_DIR="${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-java" "-c++" -package ${NAMESPACE} @@ -926,7 +925,7 @@ macro(MAKE_SWIG_TARGET_OSAPP NAME SIMPLENAME KEY_I_FILE I_FILES PARENT_TARGET PA add_custom_command( OUTPUT ${SWIG_WRAPPER} - COMMAND ${CMAKE_COMMAND} -E env SWIG_LIB="${SWIG_LIB}" + COMMAND ${CMAKE_COMMAND} -E env SWIG_DIR="${SWIG_DIR}" "${SWIG_EXECUTABLE}" "-javascript" ${SWIG_ENGINE} "-c++" #-namespace ${NAMESPACE} diff --git a/conan.lock b/conan.lock new file mode 100644 index 000000000..15f289d5c --- /dev/null +++ b/conan.lock @@ -0,0 +1,59 @@ +{ + "version": "0.5", + "requires": [ + "zlib/1.3.1#af8f2ef3d8e0fddf1975281d7fe43bf6%1705999193.687", + "websocketpp/0.8.2#842a0419153a8aa52f3ea3a1da557d38%1695972005.713", + "tinygltf/2.5.0#65c28d0a4c3cbd4ef92b08b59df769da%1701621757.442", + "termcap/1.3.1#1986f84bf21dd07ea774b027a3201fcb%1678542508.75", + "swig/4.1.1#8f418438101ef7712d52a9fe739d32f9%1707838298.077707", + "stb/cci.20230920#9792498b81cf34a90138d239e36b0bf8%1700546289.605", + "sqlite3/3.38.5#4b875d4249cdfb4c1235e6b3ea6c18e7%1676251415.466", + "ruby/3.2.2#7a66613b28107b3318a6ff60701c1b6b%1707386606.655", + "readline/8.2#5618fbfed2466d9dc0fa8834faf06a6a%1702837438.071", + "pugixml/1.12.1#d0378a7e4e32d2d379c3a272269e4330%1691917297.122", + "pcre2/10.42#74a354d74d291503aadffe6453d976f5%1694473548.558", + "openssl/3.1.0#adb90207a855ebfe1f1caa88b39c4fe0%1696808387.085", + "nlohmann_json/3.11.3#45828be26eb619a2e04ca517bb7b828d%1701220705.259", + "minizip/1.2.13#75d20b6a37ef70126334467f61acadde%1694478425.47", + "libyaml/0.2.5#67a8e4c752b3a452c4796ddc90589f74%1676469565.275", + "libxslt/1.1.37#8c0548495527cea12de08ad6212fc3ce%1703714812.414", + "libxml2/2.11.6#41c14895baba105865cb22ecaf948115%1703682489.517", + "libiconv/1.17#9d9082101394d053c67e95d3bc9f1e78%1701083487.832", + "libgettext/0.22#2c87563d7a69544dd9379f038aca3b0b%1692434363.136", + "libffi/3.4.4#35eb63842b505824b70aedc1baefc916%1682741110.044", + "libbacktrace/cci.20210118#ec1aa63bbc10145c6a299e68e711670c%1676205469.545", + "jsoncpp/1.9.5#9d91be1604af36ced56ae89ee65d53e0%1673844106.486", + "gtest/1.14.0#4372c5aed2b4018ed9f9da3e218d18b3%1691143988.385", + "gmp/6.3.0#df20ffb6d21c34d67704305bcd1dea9e%1698225617.026", + "geographiclib/1.52#924902501fa76987856594495c1d42bc%1698736427.151", + "fmt/9.1.0#551bb6d903fc22780392707fed0efb18%1704167365.696", + "cpprestsdk/2.10.19#889c41bf66e2838146eec76e3f22af8d%1701762308.51", + "bzip2/1.0.8#457c272f7da34cb9c67456dd217d36c4%1703591832.799", + "boost/1.79.0#d8a5b9e748e4152d6f489d7d87a1f129%1706000284.647", + "benchmark/1.8.3#2b95dcd66432d8ea28c5ac4db0be2fb2%1693521845.265" + ], + "build_requires": [ + "yasm/1.3.0#fb800a15413dca19bfaef9e4b5d50694%1676208399.011", + "winflexbison/2.5.25#6b08309e90720974e49b4cf745242e64%1695252638.759", + "strawberryperl/5.32.1.1#8f83d05a60363a422f9033e52d106b47%1666134191.176", + "pkgconf/2.1.0#27f44583701117b571307cf5b5fe5605%1701537936.436", + "ninja/1.11.1#77587f8c8318662ac8e5a7867eb4be21%1684431244.21", + "nasm/2.15.05#058c93b2214a49ca1cfe9f8f26205568%1703550024.076", + "msys2/cci.latest#5a31efa2bde593541fd5ac3bcc50c01c%1699871190.424", + "meson/1.2.2#aace9dcc1db58fa42ecb5292f724092d%1695994576.349", + "m4/1.4.19#b38ced39a01e31fef5435bc634461fd2%1700758725.451", + "flex/2.6.4#e35bc44b3fcbcd661e0af0dc5b5b1ad4%1674818991.113", + "cmake/3.28.1#92f79424d7b65b12a84a2180866c3a78%1703679314.116", + "cccl/1.3#6c9fc62128a11c1805de5dff1a1a0639%1668808540.988", + "bison/3.8.2#ed1ba0c42d2ab7ab64fc3a62e9ecc673%1688556312.342", + "b2/4.10.1#1b290403d8648c79f468f5a6496f829a%1699871262.816", + "automake/1.16.5#058bda3e21c36c9aa8425daf3c1faf50%1688481772.751", + "autoconf/2.71#53be95d228b2dcb30dc199cb84262d8f%1693395343.513" + ], + "python_requires": [], + "overrides": { + "boost/1.83.0": [ + "boost/1.79.0#d8a5b9e748e4152d6f489d7d87a1f129" + ] + } +} diff --git a/conanfile.py b/conanfile.py new file mode 100644 index 000000000..ee5ae3b70 --- /dev/null +++ b/conanfile.py @@ -0,0 +1,112 @@ +import sys +from pathlib import Path + +from conan import ConanFile +from conan.tools.apple import is_apple_os +from conan.tools.cmake import CMakeToolchain + +required_conan_version = ">=2.0" + + +class OpenStudioAppBuildRecipe(ConanFile): + settings = "os", "compiler", "build_type", "arch" + generators = "CMakeDeps" # CMakeToolchain explicitly instantiated + + options = { + "with_testing": [True, False], + "with_benchmark": [True, False], + } + default_options = { + "with_testing": True, + "with_benchmark": True, + } + + def requirements(self): + self.requires("ruby/3.2.2") + + if is_apple_os(self): + self.requires( + "boost/1.79.0", force=True, options={"visibility": "global"} + ) # f664bfe40e2245fa9baf1c742591d582 + else: + self.requires("boost/1.79.0", force=True) + self.requires("pugixml/1.12.1") # 5a39f82651eba3e7d6197903a3202e21 + self.requires( + "libxml2/[<2.12.0]" + ) # deprecated xmlSubstituteEntitiesDefault and co https://github.com/GNOME/libxml2/commit/db8b9722cb2a1f7dca7374ec38ecaa4936ab3869 + self.requires("libxslt/1.1.37") # 9085031f5b9b2bb328ad615cd1bf1282 + self.requires("jsoncpp/1.9.5") # 536d080aa154e5853332339bf576747c + self.requires("fmt/9.1.0") # 811e918ca4b4e0b9ddd6d5a2883efa82 + self.requires("sqlite3/3.38.5") # 010911927ce1889b5cf824f45e7cd3d2 + self.requires("cpprestsdk/2.10.19") # df2f6ac88e47cadd9c9e8e0971e00d89 + self.requires("websocketpp/0.8.2") # 3fd704c4c5388d9c08b11af86f79f616 + self.requires("geographiclib/1.52") # 76536a9315a003ef3511919310b2fe37 + self.requires("swig/4.1.1") # Pending https://github.com/conan-io/conan-center-index/pull/19058 + self.requires("tinygltf/2.5.0") # c8b2aca9505e86312bb42aa0e1c639ec + # self.requires("cli11/2.3.2") # 8ccdf14fb1ad53532d498c16ae580b4b + + self.requires( + "minizip/1.2.13" + ) # 0b5296887a2558500d0323c6c94c8d02 # This depends on zlib, and basically patches it + self.requires( + "zlib/[>=1.2.11 <2]" + ) # 3b9e037ae1c615d045a06c67d88491ae # Also needed, so we can find zlib.h and co (+ pinning exactly is good) + self.requires("openssl/[>=3 <4]") + + if self.options.with_testing: + self.requires("gtest/1.14.0") + if self.options.with_benchmark: + self.requires("benchmark/1.8.3") + + # Let people provide their own CMake for now + # def build_requirements(self): + # self.tool_requires("cmake/3.29.0") + + def generate(self): + tc = CMakeToolchain(self) + + tc.cache_variables["BUILD_CLI"] = True + tc.cache_variables["BUILD_RUBY_BINDINGS"] = True + tc.cache_variables["BUILD_PYTHON_BINDINGS"] = True + tc.cache_variables["BUILD_PYTHON_PIP_PACKAGE"] = False + + tc.cache_variables["BUILD_TESTING"] = bool(self.options.with_testing) + tc.cache_variables["BUILD_BENCHMARK"] = bool(self.options.with_benchmark) + + tc.cache_variables["CPACK_BINARY_TGZ"] = True + tc.cache_variables["CPACK_BINARY_IFW"] = False + tc.cache_variables["CPACK_BINARY_DEB"] = False + if self.settings.build_type == "Release": + if is_apple_os(self) or self.settings.os == "Windows": + tc.cache_variables["CPACK_BINARY_IFW"] = True + else: + tc.cache_variables["CPACK_BINARY_DEB"] = True + tc.cache_variables["CPACK_BINARY_NSIS"] = False + tc.cache_variables["CPACK_BINARY_RPM"] = False + tc.cache_variables["CPACK_BINARY_STGZ"] = False + tc.cache_variables["CPACK_BINARY_TBZ2"] = False + tc.cache_variables["CPACK_BINARY_TXZ"] = False + tc.cache_variables["CPACK_BINARY_TZ"] = False + + tc.cache_variables["CPACK_SOURCE_RPM"] = False + tc.cache_variables["CPACK_SOURCE_TBZ2"] = False + tc.cache_variables["CPACK_SOURCE_TGZ"] = False + tc.cache_variables["CPACK_SOURCE_TXZ"] = False + tc.cache_variables["CPACK_SOURCE_TZ"] = False + tc.cache_variables["CPACK_SOURCE_ZIP"] = False + + v = sys.version_info + if (v.major, v.minor) == (3, 8): + python_version = f"{v.major}.{v.minor}.{v.micro}" + self.output.info( + f"Setting PYTHON_VERSION and Python_ROOT_DIR from your current python: {python_version}, '{sys.base_prefix}'" + ) + tc.cache_variables["PYTHON_VERSION"] = python_version + tc.cache_variables["Python_ROOT_DIR"] = str(Path(sys.base_prefix)) + else: + self.output.warning( + "Your current python is not in the 3.8.x range, which is what we target.\n" + "You'll need to pass it properly when configuring CMake\n" + "via -DPYTHON_VERSION:STRING='3.8.xx' and -DPython_ROOT_DIR:PATH='/path/to/python3.8/'" + ) + tc.generate() diff --git a/ruby/CMakeLists.txt b/ruby/CMakeLists.txt index 770dfd32d..e5940eaab 100644 --- a/ruby/CMakeLists.txt +++ b/ruby/CMakeLists.txt @@ -19,7 +19,7 @@ add_library(openstudio_modeleditor_rb MODULE openstudio_modeleditor_rb.cpp ) -target_include_directories(openstudio_modeleditor_rb SYSTEM PRIVATE ${RUBY_INCLUDE_DIRS}) +target_include_directories(openstudio_modeleditor_rb SYSTEM PRIVATE ${Ruby_INCLUDE_DIRS}) set_target_properties(openstudio_modeleditor_rb PROPERTIES PREFIX "") set_target_properties(openstudio_modeleditor_rb PROPERTIES OUTPUT_NAME openstudio_modeleditor) diff --git a/src/model_editor/CMakeLists.txt b/src/model_editor/CMakeLists.txt index 65f1d1b2e..e8a870799 100644 --- a/src/model_editor/CMakeLists.txt +++ b/src/model_editor/CMakeLists.txt @@ -91,7 +91,7 @@ set(${target_name}_depends openstudio::openstudiolib openstudioapp_utilities ${QT_LIBS} - #CONAN_PKG::openstudio_ruby + #Ruby::Ruby ) if(WIN32) list(APPEND ${target_name}_depends qtwinmigrate) diff --git a/src/openstudio_lib/CMakeLists.txt b/src/openstudio_lib/CMakeLists.txt index b41dfdd79..5134745f8 100644 --- a/src/openstudio_lib/CMakeLists.txt +++ b/src/openstudio_lib/CMakeLists.txt @@ -719,7 +719,7 @@ set(${target_name}_moc ../shared_gui_components/NetworkProxyDialog.hpp ) -#include_directories(SYSTEM ${RUBY_INCLUDE_DIRS}) +#include_directories(SYSTEM ${Ruby_INCLUDE_DIRS}) # resource files set(${target_name}_qrc @@ -800,7 +800,7 @@ if(BUILD_BENCHMARK) message("bench_name=${bench_name}") add_executable( ${bench_name} ${bench_file} ) target_link_libraries(${bench_name} - CONAN_PKG::benchmark + benchmark::benchmark_main ${target_name} ${${target_name}_test_depends} ) diff --git a/src/utilities/CMakeLists.txt b/src/utilities/CMakeLists.txt index 860e71e3d..52754708e 100644 --- a/src/utilities/CMakeLists.txt +++ b/src/utilities/CMakeLists.txt @@ -19,7 +19,7 @@ set(${target_name}_test_src set(${target_name}_depends openstudio::openstudiolib - CONAN_PKG::boost + boost::boost ) add_library(${target_name}