Skip to content

CMake build types are hard-coded case-sensitive #1663

@anderslanglands

Description

@anderslanglands

Hello, I've got a build setup where the build type is being passed as lower case for $reasons. CMake <= 3.21 explicitly says CMAKE_BUILD_TYPE is case insensitive (3.22 and greater say "Depending on the situation, the value of this variable may be treated case-sensitively or case-insensitively" which is about as helpful as you'd expect).

In OCIO's CMakeLists.txt the following check essentially forces it to be case sensitive, which breaks my build:

if(NOT "${CMAKE_BUILD_TYPE}" IN_LIST CMAKE_CONFIGURATION_TYPES)
    string(REPLACE ";" ", " _CMAKE_CONFIGURATION_TYPES_STR "${CMAKE_CONFIGURATION_TYPES}")
    message(FATAL_ERROR 
            "CMAKE_BUILD_TYPE=${CMAKE_BUILD_TYPE} is unsupported. Supported values are: ${_CMAKE_CONFIGURATION_TYPES_STR}.")
endif()

which is especially annoying because you do an explicitly case-insensitive check for "Debug" directly underneath :)

set(_BUILD_TYPE_DEBUG OFF)
if(CMAKE_BUILD_TYPE MATCHES "[Dd][Ee][Bb][Uu][Gg]")
    set(_BUILD_TYPE_DEBUG ON)
endif()

Is that check on the build type really necessary? It's not an idiom I've seen elsewhere. I started trying to figure out how to rewrite it cleanly in a case-insensitive way but cmake gave me a headache so I just removed it completely on my fork to get my build working.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions