From 4185406a42f947c1d6afa0fa84eddf71445e4b95 Mon Sep 17 00:00:00 2001 From: Gabriel Ferreira Date: Mon, 31 Oct 2022 10:18:42 -0300 Subject: [PATCH] build: (fixes #799) export ns-3 build profile names in version.cache --- build-support/custom-modules/ns3-versioning.cmake | 9 ++++++++- ns3 | 7 ++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/build-support/custom-modules/ns3-versioning.cmake b/build-support/custom-modules/ns3-versioning.cmake index 84b646011..02a9f71f8 100644 --- a/build-support/custom-modules/ns3-versioning.cmake +++ b/build-support/custom-modules/ns3-versioning.cmake @@ -139,7 +139,14 @@ function(configure_embedded_version) if(${NS3_VERSION_RELEASE_CANDIDATE} STREQUAL " ") set(NS3_VERSION_RELEASE_CANDIDATE \"\") endif() - set(NS3_VERSION_BUILD_PROFILE ${cmakeBuildType}) + + if(${cmakeBuildType} STREQUAL relwithdebinfo) + set(NS3_VERSION_BUILD_PROFILE default) + elseif((${cmakeBuildType} STREQUAL release) AND ${NS3_NATIVE_OPTIMIZATIONS}) + set(NS3_VERSION_BUILD_PROFILE optimized) + else() + set(NS3_VERSION_BUILD_PROFILE ${cmakeBuildType}) + endif() set(version_cache_file_template ${PROJECT_SOURCE_DIR}/build-support/version.cache.in diff --git a/ns3 b/ns3 index 5b7726fae..db6d99361 100755 --- a/ns3 +++ b/ns3 @@ -110,7 +110,7 @@ def parse_args(argv): parser_configure.add_argument('-d', '--build-profile', help='Build profile', dest='build_profile', - choices=["debug", "default", "release", "optimized"], + choices=["debug", "default", "release", "optimized", "minsizerel"], action="store", type=str, default=None) parser_configure.add_argument('-G', @@ -552,7 +552,7 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener # Build type if args.build_profile is not None: args.build_profile = args.build_profile.lower() - if args.build_profile not in ["debug", "default", "release", "optimized"]: + if args.build_profile not in ["debug", "default", "release", "optimized", "minsizerel"]: raise Exception("Unknown build type") else: if args.build_profile == "debug": @@ -563,7 +563,8 @@ def configure_cmake(cmake, args, current_cmake_cache_folder, current_cmake_gener "-DCMAKE_BUILD_TYPE=default -DNS3_ASSERT=ON -DNS3_LOG=ON -DNS3_WARNINGS_AS_ERRORS=OFF".split()) else: cmake_args.extend( - "-DCMAKE_BUILD_TYPE=release -DNS3_ASSERT=OFF -DNS3_LOG=OFF -DNS3_WARNINGS_AS_ERRORS=OFF".split() + f"-DCMAKE_BUILD_TYPE={args.build_profile} -DNS3_ASSERT=OFF -DNS3_LOG=OFF " + f"-DNS3_WARNINGS_AS_ERRORS=OFF".split() ) cmake_args.append("-DNS3_NATIVE_OPTIMIZATIONS=%s" % on_off((args.build_profile == "optimized")))