From f4a3bfd2a3421f56730346983d1447176e409c51 Mon Sep 17 00:00:00 2001 From: Pieter Pas Date: Mon, 6 May 2024 13:10:06 +0200 Subject: [PATCH] Update CMakePresets.json --- CMakePresets.json | 65 +++++++++++++++++++++++++--------- scripts/dev/install-locally.sh | 12 +++---- 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/CMakePresets.json b/CMakePresets.json index 8e57f79f24..f14b9e68c1 100644 --- a/CMakePresets.json +++ b/CMakePresets.json @@ -1,43 +1,75 @@ { "version": 4, "configurePresets": [ + { + "name": ".dev-vars", + "description": "Default options for developer builds", + "hidden": true, + "warnings": { + "dev": true + }, + "cacheVariables": { + "CMAKE_POSITION_INDEPENDENT_CODE": true, + "CMAKE_EXPORT_COMPILE_COMMANDS": true, + "BUILD_SHARED_LIBS": true, + "CMAKE_STAGING_PREFIX": "${sourceDir}/staging", + "ALPAQA_WITH_DRIVERS": true, + "ALPAQA_WITH_EXAMPLES": true, + "ALPAQA_WITH_TESTS": true + } + }, { "name": ".dev-linux", + "description": "Default settings for developer builds on Linux", "hidden": true, + "inherits": [ + ".dev-vars" + ], "generator": "Ninja Multi-Config", + "binaryDir": "${sourceDir}/build", "warnings": { "dev": true, "deprecated": true, "uninitialized": true }, + "environment": { + "CFLAGS": "-fdiagnostics-color", + "CXXFLAGS": "-fdiagnostics-color", + "FCFLAGS": "-fdiagnostics-color" + }, + "cacheVariables": { + "CMAKE_C_COMPILER_LAUNCHER": "ccache", + "CMAKE_CXX_COMPILER_LAUNCHER": "ccache" + } + }, + { + "name": ".dev-linux-cross-native", + "description": "Configuration for cross-compiling using local x86_64-centos7-linux-gnu toolchain (with -march=native)", + "hidden": true, + "inherits": [ + ".dev-linux" + ], "environment": { "CFLAGS": "-march=native -fdiagnostics-color", "CXXFLAGS": "-march=native -fdiagnostics-color", "FCFLAGS": "-march=native -fdiagnostics-color", + "LDFLAGS": "-static-libstdc++", "CROSS_COMPILE": "x86_64-centos7-linux-gnu", "TOOLCHAIN_PREFIX": "${sourceDir}/toolchains/$env{CROSS_COMPILE}" }, "toolchainFile": "$env{TOOLCHAIN_PREFIX}/$env{CROSS_COMPILE}.toolchain.cmake", "cacheVariables": { - "CMAKE_C_COMPILER_LAUNCHER": "ccache", - "CMAKE_CXX_COMPILER_LAUNCHER": "ccache", "CMAKE_PREFIX_PATH": "$env{TOOLCHAIN_PREFIX}/mumps/usr/local;$env{TOOLCHAIN_PREFIX}/ipopt/usr/local", - "CMAKE_FIND_ROOT_PATH": "$env{TOOLCHAIN_PREFIX}/eigen-master;$env{TOOLCHAIN_PREFIX}/googletest;$env{TOOLCHAIN_PREFIX}/casadi;$env{TOOLCHAIN_PREFIX}/openblas;$env{TOOLCHAIN_PREFIX}/mumps;$env{TOOLCHAIN_PREFIX}/ipopt;$env{TOOLCHAIN_PREFIX}/qpalm;$env{TOOLCHAIN_PREFIX}/pybind11-2.11.1", - "CMAKE_POSITION_INDEPENDENT_CODE": true + "CMAKE_FIND_ROOT_PATH": "$env{TOOLCHAIN_PREFIX}/eigen-master;$env{TOOLCHAIN_PREFIX}/googletest;$env{TOOLCHAIN_PREFIX}/casadi;$env{TOOLCHAIN_PREFIX}/openblas;$env{TOOLCHAIN_PREFIX}/mumps;$env{TOOLCHAIN_PREFIX}/ipopt;$env{TOOLCHAIN_PREFIX}/qpalm;$env{TOOLCHAIN_PREFIX}/pybind11-2.11.1" } }, { - "name": "dev-linux", + "name": "dev-linux-cross-native", + "description": "Configuration for cross-compiling using local x86_64-centos7-linux-gnu toolchain (with -march=native)", "inherits": [ - ".dev-linux" + ".dev-linux-cross-native" ], - "binaryDir": "${sourceDir}/build-local", "cacheVariables": { - "BUILD_SHARED_LIBS": true, - "CMAKE_STAGING_PREFIX": "${sourceDir}/staging", - "ALPAQA_WITH_DRIVERS": true, - "ALPAQA_WITH_EXAMPLES": false, - "ALPAQA_WITH_TESTS": false, "ALPAQA_WITH_CUTEST": true, "ALPAQA_WITH_QPALM": true, "ALPAQA_WITH_IPOPT": true, @@ -45,13 +77,14 @@ } }, { - "name": "dev-linux-python", + "name": "dev-linux-cross-native-python", + "description": "Configuration for cross-compiling Python bindings using local x86_64-centos7-linux-gnu toolchain (with -march=native)", "inherits": [ - ".dev-linux" + ".dev-linux-cross-native" ], - "binaryDir": "${sourceDir}/build-python", + "binaryDir": "${sourceDir}/build/python", "cacheVariables": { - "CMAKE_MODULE_LINKER_FLAGS": "-static-libstdc++", + "BUILD_SHARED_LIBS": false, "ALPAQA_PYTHON_DEBUG_CONFIG": "Debug", "USE_GLOBAL_PYBIND11": true, "ALPAQA_WITH_PY_STUBS": true, diff --git a/scripts/dev/install-locally.sh b/scripts/dev/install-locally.sh index c5cd89a3fe..c12c79e4ea 100755 --- a/scripts/dev/install-locally.sh +++ b/scripts/dev/install-locally.sh @@ -25,15 +25,15 @@ if [ ! -d "$pfx/qpalm" ]; then fi # Configure -cmake --preset dev-linux +cmake --preset dev-linux-cross-native # Build for cfg in Debug RelWithDebInfo; do - cmake --build build-local -j --config $cfg - cmake --install build-local --config $cfg - cmake --install build-local --config $cfg --component debug + cmake --build build -j --config $cfg + cmake --install build --config $cfg + cmake --install build --config $cfg --component debug done # Package -pushd build-local +pushd build cpack -G 'TGZ;DEB' -C "RelWithDebInfo;Debug" popd @@ -43,7 +43,7 @@ cat <<- EOF > "$config" [cmake] config = ["Debug", "Release"] generator = "Ninja Multi-Config" -preset = "dev-linux-python" +preset = "dev-linux-cross-native-python" EOF . ./.venv/bin/activate pip install -U pip build