Skip to content

Commit

Permalink
Obey CMAKE_BUILD_TYPE
Browse files Browse the repository at this point in the history
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
  • Loading branch information
benrichard-amd committed Feb 7, 2025
1 parent fad2fcd commit 515a5dd
Showing 1 changed file with 16 additions and 13 deletions.
29 changes: 16 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -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})
Expand All @@ -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.
#
Expand All @@ -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()

Expand Down

0 comments on commit 515a5dd

Please sign in to comment.