From 060726826026730a9e2cefc5920f397da484953c Mon Sep 17 00:00:00 2001 From: benrichard-amd Date: Fri, 7 Feb 2025 08:43:47 -0800 Subject: [PATCH] Obey CMAKE_BUILD_TYPE Obey CMAKE_BUILD_TYPE when it is passed on the command line. Previous behavior remains: Debug by default ROCRTST_BLD_TYPE can set build type --- CMakeLists.txt | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index f24e26cb42..212ca0e463 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -46,6 +46,11 @@ if(WIN32) return() endif() +# Debug by default +if(NOT CMAKE_BUILD_TYPE) + set(CMAKE_BUILD_TYPE "Debug") +endif() + # Generate static package, when BUILD_SHARED_LIBS is set to OFF. # Default to ON option(BUILD_SHARED_LIBS "Build using shared libraries" ON) @@ -62,13 +67,15 @@ include(utils) find_package(hsa-runtime64 1.0 REQUIRED ) -string(TOLOWER "${ROCRTST_BLD_TYPE}" tmp) -if("${tmp}" STREQUAL release) - set(BUILD_TYPE "Release") - set(ISDEBUG 0) -else() - set(BUILD_TYPE "Debug") - set(ISDEBUG 1) +if(DEFINED ROCRTST_BLD_TYPE) + string(TOLOWER "${ROCRTST_BLD_TYPE}" tmp) + if("${tmp}" STREQUAL release) + set(CMAKE_BUILD_TYPE "Release") + set(ISDEBUG 0) + else() + set(CMAKE_BUILD_TYPE "Debug") + set(ISDEBUG 1) + endif() endif() # The following default version values should be updated as appropriate for @@ -100,7 +107,7 @@ message("Package version: ${PKG_VERSION_STR}") # message("") message("Build Configuration:") -message("-----------BuildType: " ${BUILD_TYPE}) +message("-----------BuildType: " ${CMAKE_BUILD_TYPE}) message("------------Compiler: " ${CMAKE_CXX_COMPILER}) message("-------------Version: " ${CMAKE_CXX_COMPILER_VERSION}) message("--------Proj Src Dir: " ${PROJECT_SOURCE_DIR}) @@ -110,10 +117,6 @@ message("--------Proj Exe Dir: " ${PROJECT_BINARY_DIR}/bin) message("") -# -# Set the build type based on user input -# -set(CMAKE_BUILD_TYPE ${BUILD_TYPE}) # # Flag to enable / disable verbose output. # @@ -122,7 +125,7 @@ SET( CMAKE_VERBOSE_MAKEFILE on ) # Compiler pre-processor definitions. # # Define MACRO "DEBUG" if build type is "Debug" -if(${BUILD_TYPE} STREQUAL "Debug") +if(${CMAKE_BUILD_TYPE} STREQUAL "Debug") add_definitions(-DDEBUG) endif()