Skip to content

Commit

Permalink
Using specified C++ standard to build generated projects.
Browse files Browse the repository at this point in the history
  • Loading branch information
arobenko committed Sep 25, 2024
1 parent a398715 commit 2fe6901
Show file tree
Hide file tree
Showing 5 changed files with 69 additions and 29 deletions.
10 changes: 5 additions & 5 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@ if (UBLOX_GEN_PROTOCOL)
-DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
-DOPT_REQUIRE_COMMS_LIB=OFF
-DOPT_REQUIRE_COMMS_LIB=OFF -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
)

Expand Down Expand Up @@ -382,7 +382,7 @@ if (UBLOX_GEN_TEST)
-DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_PREFIX_PATH=${combined_prefix_path_str}
-DOPT_TEST_OPTIONS=cc_ublox::options::AllMessagesDynMemMsgFactoryDefaultOptions
-DOPT_USE_CCACHE=${UBLOX_USE_CCACHE}
Expand Down Expand Up @@ -446,7 +446,7 @@ if (UBLOX_GEN_TOOLS)
-DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_PREFIX_PATH=${combined_prefix_path_str}
-DOPT_QT_MAJOR_VERSION=${UBLOX_TOOLS_QT_VER}
-DOPT_USE_CCACHE=${UBLOX_USE_CCACHE}
Expand Down Expand Up @@ -510,7 +510,7 @@ if (UBLOX_GEN_SWIG)
-DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_GENERATOR_TOOLSET=${CMAKE_GENERATOR_TOOLSET} -DCMAKE_TOOLCHAIN_FILE=${CMAKE_TOOLCHAIN_FILE}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} -DCMAKE_EXE_LINKER_FLAGS=${CMAKE_EXE_LINKER_FLAGS}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DCMAKE_PREFIX_PATH=${combined_prefix_path_str}
-DOPT_SWIG_LANGUAGES=${combined_languages_str}
-DOPT_USE_CCACHE=${UBLOX_USE_CCACHE}
Expand Down Expand Up @@ -581,7 +581,7 @@ if (UBLOX_GEN_EMSCRIPTEN)
CMAKE_ARGS
-DCMAKE_GENERATOR=${CMAKE_GENERATOR} -DCMAKE_GENERATOR_PLATFORM=${CMAKE_GENERATOR_PLATFORM}
-DCMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX}
-DCMAKE_INSTALL_PREFIX=${CMAKE_INSTALL_PREFIX} -DCMAKE_CXX_STANDARD=${CMAKE_CXX_STANDARD}
-DOPT_MODULARIZE=ON
-DOPT_EXTRA_INCLUDE_DIRS=${extra_includes_path_str}
-DOPT_USE_CCACHE=${UBLOX_USE_CCACHE}
Expand Down
39 changes: 39 additions & 0 deletions script/full_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
#!/bin/bash

if [ -z "${CC}" -o -z "$CXX" ]; then
echo "ERROR: Compilers are not provided"
exit 1
fi

if [ -z "${COMMON_BUILD_TYPE}" ]; then
echo "ERROR: Build type is not provided"
exit 1
fi


SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR=$( dirname ${SCRIPT_DIR} )

if [ -z ${BUILD_DIR} ]; then
export BUILD_DIR="${ROOT_DIR}/build.full.${CC}.${COMMON_BUILD_TYPE}"
fi

export COMMON_INSTALL_DIR=${BUILD_DIR}/install
export EXTERNALS_DIR=${ROOT_DIR}/externals
export COMMON_USE_CCACHE=ON
mkdir -p ${BUILD_DIR}

${SCRIPT_DIR}/prepare_externals.sh

cd ${BUILD_DIR}
cmake .. -DCMAKE_INSTALL_PREFIX=${COMMON_INSTALL_DIR} \
-DCMAKE_BUILD_TYPE=${COMMON_BUILD_TYPE} -DUBLOX_GEN_TEST=ON \
-DUBLOX_GEN_TOOLS=ON -DUBLOX_GEN_SWIG=OFF -DUBLOX_GEN_EMSCRIPTEN=OFF \
-DUBLOX_BUILD_EXAMPLES=ON -DUBLOX_USE_CCACHE=ON "$@"

procs=$(nproc)
if [ -n "${procs}" ]; then
procs_param="--parallel ${procs}"
fi

cmake --build ${BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param}
25 changes: 1 addition & 24 deletions script/full_debug_build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,29 +6,6 @@ if [ -z "${CC}" -o -z "$CXX" ]; then
fi

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
ROOT_DIR=$( dirname ${SCRIPT_DIR} )

if [ -z ${BUILD_DIR} ]; then
export BUILD_DIR="${ROOT_DIR}/build.full.${CC}"
fi

export COMMON_INSTALL_DIR=${BUILD_DIR}/install
export COMMON_BUILD_TYPE=Debug
export EXTERNALS_DIR=${ROOT_DIR}/externals
export COMMON_USE_CCACHE=ON
mkdir -p ${BUILD_DIR}

${SCRIPT_DIR}/prepare_externals.sh

cd ${BUILD_DIR}
cmake .. -DCMAKE_INSTALL_PREFIX=${COMMON_INSTALL_DIR} \
-DCMAKE_BUILD_TYPE=Debug -DUBLOX_GEN_TEST=ON \
-DUBLOX_GEN_TOOLS=ON -DUBLOX_GEN_SWIG=OFF -DUBLOX_GEN_EMSCRIPTEN=OFF \
-DUBLOX_BUILD_EXAMPLES=ON -DUBLOX_USE_CCACHE=ON "$@"

procs=$(nproc)
if [ -n "${procs}" ]; then
procs_param="--parallel ${procs}"
fi
exec ${SCRIPT_DIR}/full_build.sh "$@"

cmake --build ${BUILD_DIR} --config ${COMMON_BUILD_TYPE} --target install ${procs_param}
11 changes: 11 additions & 0 deletions script/full_release_build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
#!/bin/bash

if [ -z "${CC}" -o -z "$CXX" ]; then
echo "ERROR: Compilers are not provided"
exit 1
fi

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
export COMMON_BUILD_TYPE=Release
exec ${SCRIPT_DIR}/full_build.sh "$@"

13 changes: 13 additions & 0 deletions script/full_release_build_gcc.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/bin/bash

if [ -z "${CC}" ]; then
export CC=gcc
fi

if [ -z "${CXX}" ]; then
export CXX=g++
fi

SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
${SCRIPT_DIR}/full_release_build.sh "$@"

0 comments on commit 2fe6901

Please sign in to comment.