Skip to content

Commit

Permalink
Improve handling of cmake build type
Browse files Browse the repository at this point in the history
  • Loading branch information
chapman39 committed Jan 28, 2025
1 parent 4dfae88 commit ad7e181
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions config-build.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ def parse_arguments():
"--buildtype",
type=str,
choices=["Release", "Debug", "RelWithDebInfo", "MinSizeRel"],
default="Debug",
help="build type.")
help="build type. defaults to Debug")

parser.add_argument("-e",
"--eclipse",
Expand Down Expand Up @@ -105,8 +104,6 @@ def parse_arguments():
action='store_true',
help="use ninja generator to build serac instead of make")



args, unknown_args = parser.parse_known_args()
if unknown_args:
print("[config-build]: Passing the following arguments directly to cmake... %s" % unknown_args)
Expand Down Expand Up @@ -230,6 +227,7 @@ def create_cmake_command_line(args, unknown_args, buildpath, installpath, hostco

# Add build type (opt or debug)
cmakeline += " -DCMAKE_BUILD_TYPE=" + args.buildtype

# Set install dir
cmakeline += " -DCMAKE_INSTALL_PREFIX=%s" % installpath

Expand Down Expand Up @@ -277,7 +275,7 @@ def run_cmake(buildpath, cmakeline):
# Main
############################
def main():
repodir = os.path.abspath(os.path.dirname(__file__))
repodir = os.path.abspath(os.path.dirname(__file__))
assert os.path.abspath(os.getcwd())==repodir, "config-build must be run from %s" % repodir

args, unknown_args = parse_arguments()
Expand All @@ -295,6 +293,15 @@ def main():
else:
return False

# CMake build type is Debug by default, but if CMAKE_BUILD_TYPE is an unknown argument (i.e. a CMake argument), then
# use that option instead.
if args.buildtype == None:
args.buildtype = "Debug"
for unknown_arg in unknown_args:
if "-DCMAKE_BUILD_TYPE" in unknown_arg:
args.buildtype = unknown_arg.split("=")[1]
break

basehostconfigpath = find_host_config(args, repodir)
platform_info = get_platform_info(basehostconfigpath)
buildpath = setup_build_dir(args, platform_info)
Expand Down

0 comments on commit ad7e181

Please sign in to comment.