Skip to content

Commit

Permalink
CMake: Warn Unknown Build Type (#563)
Browse files Browse the repository at this point in the history
Warn if a build type passed by a user is not known in project build.

```
CMake Warning at cmake/HiPACEFunctions.cmake:76 (message):
  CMAKE_BUILD_TYPE 'adsads' is not one of
  Release;Debug;MinSizeRel;RelWithDebInfo.  Is this a typo?
Call Stack (most recent call first):
  CMakeLists.txt:94 (set_default_build_type)
```

Summary:
```
  Build type: adsads (unknown type, check warning)
```

This helps if one accidentially writes `debug` instead of `Debug`,
for instance. The result of a custom type that is undefined are no
compiler (optimization/debug) flags at all...
  • Loading branch information
ax3l authored Jul 15, 2021
1 parent babbaa2 commit 21304bb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion cmake/HiPACEFunctions.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ macro(set_default_build_type default_build_type)
set_property(CACHE CMAKE_BUILD_TYPE
PROPERTY STRINGS ${CMAKE_CONFIGURATION_TYPES})
endif()
if(NOT CMAKE_BUILD_TYPE IN_LIST CMAKE_CONFIGURATION_TYPES)
message(WARNING "CMAKE_BUILD_TYPE '${CMAKE_BUILD_TYPE}' is not one of "
"${CMAKE_CONFIGURATION_TYPES}. Is this a typo?")
endif()
endif()
endmacro()

Expand Down Expand Up @@ -219,7 +223,12 @@ function(hipace_print_summary)
message(" python: ${CMAKE_INSTALL_PYTHONDIR}")
endif()
message("")
message(" Build type: ${CMAKE_BUILD_TYPE}")
set(BLD_TYPE_UNKNOWN "")
if(CMAKE_SOURCE_DIR STREQUAL PROJECT_SOURCE_DIR AND
NOT CMAKE_BUILD_TYPE IN_LIST CMAKE_CONFIGURATION_TYPES)
set(BLD_TYPE_UNKNOWN " (unknown type, check warning)")
endif()
message(" Build type: ${CMAKE_BUILD_TYPE}${BLD_TYPE_UNKNOWN}")
#if(BUILD_SHARED_LIBS)
# message(" Library: shared")
#else()
Expand Down

0 comments on commit 21304bb

Please sign in to comment.