Skip to content

Disable CMake build type checks on Windows #386

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion .github/workflows/basic.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,6 @@ jobs:
-B ${{env.BUILD_DIR}}
${{matrix.toolset}}
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}
Expand Down
6 changes: 5 additions & 1 deletion .github/workflows/benchmarks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ jobs:
strategy:
matrix:
os: ['ubuntu-latest', 'windows-latest']
include:
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command to determine the build type
- os: ubuntu-latest
extra_build_option: '-DCMAKE_BUILD_TYPE=Release'
runs-on: ${{matrix.os}}

steps:
Expand Down Expand Up @@ -44,7 +48,7 @@ jobs:
run: >
cmake
-B ${{env.BUILD_DIR}}
-DCMAKE_BUILD_TYPE=Release
${{matrix.extra_build_option}}
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
-DUMF_BUILD_SHARED_LIBRARY=ON
-DUMF_BUILD_BENCHMARKS=ON
Expand Down
84 changes: 48 additions & 36 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,31 +41,51 @@ set(UMF_PROXY_LIB_BASED_ON_POOL
set_property(CACHE UMF_PROXY_LIB_BASED_ON_POOL
PROPERTY STRINGS ${KNOWN_PROXY_LIB_POOLS})

set(KNOWN_BUILD_TYPES Release Debug RelWithDebInfo MinSizeRel)
string(REPLACE ";" " " KNOWN_BUILD_TYPES_STR "${KNOWN_BUILD_TYPES}")

if(NOT CMAKE_BUILD_TYPE)
message(
STATUS
"No build type selected (CMAKE_BUILD_TYPE), defaulting to Release")
set(CMAKE_BUILD_TYPE "Release")
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
set(OS_NAME "linux")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS TRUE)
set(OS_NAME "windows")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
set(OS_NAME "macosx")
else()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
if(NOT CMAKE_BUILD_TYPE IN_LIST KNOWN_BUILD_TYPES)
message(FATAL_ERROR "Unknown OS type")
endif()

# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
# set, because in this case the build type is determined after a CMake
# configuration is done (at the build time)
if(NOT WINDOWS)
set(KNOWN_BUILD_TYPES Release Debug RelWithDebInfo MinSizeRel)
string(REPLACE ";" " " KNOWN_BUILD_TYPES_STR "${KNOWN_BUILD_TYPES}")

if(NOT CMAKE_BUILD_TYPE)
message(
WARNING
"Unusual build type was set (${CMAKE_BUILD_TYPE}), please make sure it is a correct one. "
"The following ones are supported by default: ${KNOWN_BUILD_TYPES_STR}."
STATUS
"No build type selected (CMAKE_BUILD_TYPE), defaulting to Release"
)
set(CMAKE_BUILD_TYPE "Release")
else()
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
if(NOT CMAKE_BUILD_TYPE IN_LIST KNOWN_BUILD_TYPES)
message(
WARNING
"Unusual build type was set (${CMAKE_BUILD_TYPE}), please make sure it is a correct one. "
"The following ones are supported by default: ${KNOWN_BUILD_TYPES_STR}."
)
endif()
endif()
endif()

set(CMAKE_BUILD_TYPE
"${CMAKE_BUILD_TYPE}"
CACHE STRING
"Choose the type of build, options are: ${KNOWN_BUILD_TYPES_STR} ..."
FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${KNOWN_BUILD_TYPES})
set(CMAKE_BUILD_TYPE
"${CMAKE_BUILD_TYPE}"
CACHE
STRING
"Choose the type of build, options are: ${KNOWN_BUILD_TYPES_STR} ..."
FORCE)
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${KNOWN_BUILD_TYPES})
endif()

# For using the options listed in the OPTIONS_REQUIRING_CXX variable a C++17
# compiler is required. Moreover, if these options are not set, CMake will set
Expand All @@ -89,19 +109,6 @@ find_package(PkgConfig)
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(helpers)

if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
set(LINUX TRUE)
set(OS_NAME "linux")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
set(WINDOWS TRUE)
set(OS_NAME "windows")
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
set(MACOSX TRUE)
set(OS_NAME "macosx")
else()
message(FATAL_ERROR "Unknown OS type")
endif()

# needed when UMF is used as an external project
set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})

Expand Down Expand Up @@ -190,13 +197,18 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
endif()

# set UMF_PROXY_LIB_ENABLED
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
if(WINDOWS)
# TODO: enable the proxy library in the Debug build on Windows
#
# In MSVC builds, there is no way to determine the actual build type during
# the CMake configuration step. Therefore, this message is printed in all
# MSVC builds.
message(
STATUS
"Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})"
"The proxy library will be built, however it is supported only in the Release build on Windows"
)
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
endif()
if(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
set(UMF_PROXY_LIB_ENABLED ON)
set(PROXY_LIB_USES_SCALABLE_POOL ON)
Expand Down
10 changes: 8 additions & 2 deletions benchmark/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,14 @@
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

if(CMAKE_BUILD_TYPE STREQUAL "Debug")
message(WARNING "The benchmarks SHOULD NOT be run in the Debug build type!")
# In MSVC builds, there is no way to determine the actual build type during the
# CMake configuration step. Therefore, this message is printed in all MSVC
# builds.
if(WINDOWS OR NOT CMAKE_BUILD_TYPE STREQUAL "Release")
message(
STATUS
"The benchmarks SHOULD NOT be run in the Debug build type! The benchmarks will be built, however their output is relevant only in the Release build!"
)
endif()

if(UMF_BUILD_BENCHMARKS_MT)
Expand Down
6 changes: 1 addition & 5 deletions test/test_installation.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ def _create_match_list(self) -> List[str]:
lib_prefix = "lib"

# Currently the proxy library uses and requires the scalable pool
# The proxy library does not work in the Debug build on Windows yet.
if ("scalable_pool" in self.pools) and not (platform.system() == "Windows" and self.build_type == "debug"):
is_umf_proxy = True
else:
is_umf_proxy = False
is_umf_proxy = True if "scalable_pool" in self.pools else False

bin = []
if platform.system() == "Windows" and (self.shared_library or is_umf_proxy):
Expand Down