Skip to content

Commit dd56f12

Browse files
committed
Disable CMake build type checks on Windows
Do not rely on the CMAKE_BUILD_TYPE configuration variable in Windows builds. This variable is ignored by MSVC, the build type is determined during the build time based on the '--config' parameter. There seems to be no way for disabling the proxy library build based on the used config, so this change provides just notification messages on all Windows builds and builds proxy library always.
1 parent 3ff9eac commit dd56f12

File tree

5 files changed

+62
-45
lines changed

5 files changed

+62
-45
lines changed

.github/workflows/basic.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,6 @@ jobs:
226226
-B ${{env.BUILD_DIR}}
227227
${{matrix.toolset}}
228228
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
229-
-DCMAKE_BUILD_TYPE=${{matrix.build_type}}
230229
-DCMAKE_C_COMPILER=${{matrix.compiler.c}}
231230
-DCMAKE_CXX_COMPILER=${{matrix.compiler.cxx}}
232231
-DUMF_BUILD_SHARED_LIBRARY=${{matrix.shared_library}}

.github/workflows/benchmarks.yml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ jobs:
1515
strategy:
1616
matrix:
1717
os: ['ubuntu-latest', 'windows-latest']
18+
include:
19+
# Windows doesn't recognize 'CMAKE_BUILD_TYPE', it uses '--config' param in build command to determine the build type
20+
- os: ubuntu-latest
21+
extra_build_option: '-DCMAKE_BUILD_TYPE=Release'
1822
runs-on: ${{matrix.os}}
1923

2024
steps:
@@ -44,7 +48,7 @@ jobs:
4448
run: >
4549
cmake
4650
-B ${{env.BUILD_DIR}}
47-
-DCMAKE_BUILD_TYPE=Release
51+
${{matrix.extra_build_option}}
4852
-DCMAKE_PREFIX_PATH="${{env.VCPKG_PATH}}"
4953
-DUMF_BUILD_SHARED_LIBRARY=ON
5054
-DUMF_BUILD_BENCHMARKS=ON

CMakeLists.txt

Lines changed: 48 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -41,31 +41,51 @@ set(UMF_PROXY_LIB_BASED_ON_POOL
4141
set_property(CACHE UMF_PROXY_LIB_BASED_ON_POOL
4242
PROPERTY STRINGS ${KNOWN_PROXY_LIB_POOLS})
4343

44-
set(KNOWN_BUILD_TYPES Release Debug RelWithDebInfo MinSizeRel)
45-
string(REPLACE ";" " " KNOWN_BUILD_TYPES_STR "${KNOWN_BUILD_TYPES}")
46-
47-
if(NOT CMAKE_BUILD_TYPE)
48-
message(
49-
STATUS
50-
"No build type selected (CMAKE_BUILD_TYPE), defaulting to Release")
51-
set(CMAKE_BUILD_TYPE "Release")
44+
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
45+
set(LINUX TRUE)
46+
set(OS_NAME "linux")
47+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
48+
set(WINDOWS TRUE)
49+
set(OS_NAME "windows")
50+
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
51+
set(MACOSX TRUE)
52+
set(OS_NAME "macosx")
5253
else()
53-
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
54-
if(NOT CMAKE_BUILD_TYPE IN_LIST KNOWN_BUILD_TYPES)
54+
message(FATAL_ERROR "Unknown OS type")
55+
endif()
56+
57+
# This build type check is not possible on Windows when CMAKE_BUILD_TYPE is not
58+
# set, because in this case the build type is determined after a CMake
59+
# configuration is done (at the build time)
60+
if(NOT WINDOWS)
61+
set(KNOWN_BUILD_TYPES Release Debug RelWithDebInfo MinSizeRel)
62+
string(REPLACE ";" " " KNOWN_BUILD_TYPES_STR "${KNOWN_BUILD_TYPES}")
63+
64+
if(NOT CMAKE_BUILD_TYPE)
5565
message(
56-
WARNING
57-
"Unusual build type was set (${CMAKE_BUILD_TYPE}), please make sure it is a correct one. "
58-
"The following ones are supported by default: ${KNOWN_BUILD_TYPES_STR}."
66+
STATUS
67+
"No build type selected (CMAKE_BUILD_TYPE), defaulting to Release"
5968
)
69+
set(CMAKE_BUILD_TYPE "Release")
70+
else()
71+
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}")
72+
if(NOT CMAKE_BUILD_TYPE IN_LIST KNOWN_BUILD_TYPES)
73+
message(
74+
WARNING
75+
"Unusual build type was set (${CMAKE_BUILD_TYPE}), please make sure it is a correct one. "
76+
"The following ones are supported by default: ${KNOWN_BUILD_TYPES_STR}."
77+
)
78+
endif()
6079
endif()
61-
endif()
6280

63-
set(CMAKE_BUILD_TYPE
64-
"${CMAKE_BUILD_TYPE}"
65-
CACHE STRING
66-
"Choose the type of build, options are: ${KNOWN_BUILD_TYPES_STR} ..."
67-
FORCE)
68-
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${KNOWN_BUILD_TYPES})
81+
set(CMAKE_BUILD_TYPE
82+
"${CMAKE_BUILD_TYPE}"
83+
CACHE
84+
STRING
85+
"Choose the type of build, options are: ${KNOWN_BUILD_TYPES_STR} ..."
86+
FORCE)
87+
set_property(CACHE CMAKE_BUILD_TYPE PROPERTY STRINGS ${KNOWN_BUILD_TYPES})
88+
endif()
6989

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

92-
if(${CMAKE_SYSTEM_NAME} MATCHES "Linux")
93-
set(LINUX TRUE)
94-
set(OS_NAME "linux")
95-
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Windows")
96-
set(WINDOWS TRUE)
97-
set(OS_NAME "windows")
98-
elseif(${CMAKE_SYSTEM_NAME} MATCHES "Darwin")
99-
set(MACOSX TRUE)
100-
set(OS_NAME "macosx")
101-
else()
102-
message(FATAL_ERROR "Unknown OS type")
103-
endif()
104-
105112
# needed when UMF is used as an external project
106113
set(UMF_CMAKE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR})
107114

@@ -190,13 +197,18 @@ if(UMF_BUILD_LIBUMF_POOL_JEMALLOC)
190197
endif()
191198

192199
# set UMF_PROXY_LIB_ENABLED
193-
if(WINDOWS AND NOT (CMAKE_BUILD_TYPE STREQUAL "Release"))
200+
if(WINDOWS)
194201
# TODO: enable the proxy library in the Debug build on Windows
202+
#
203+
# In MSVC builds, there is no way to determine the actual build type during
204+
# the CMake configuration step. Therefore, this message is printed in all
205+
# MSVC builds.
195206
message(
196207
STATUS
197-
"Disabling the proxy library, because it is supported only in the Release build on Windows (CMAKE_BUILD_TYPE = ${CMAKE_BUILD_TYPE})"
208+
"The proxy library will be built, however it is supported only in the Release build on Windows"
198209
)
199-
elseif(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
210+
endif()
211+
if(UMF_PROXY_LIB_BASED_ON_POOL STREQUAL SCALABLE)
200212
if(UMF_BUILD_LIBUMF_POOL_SCALABLE)
201213
set(UMF_PROXY_LIB_ENABLED ON)
202214
set(PROXY_LIB_USES_SCALABLE_POOL ON)

benchmark/CMakeLists.txt

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,14 @@
22
# Under the Apache License v2.0 with LLVM Exceptions. See LICENSE.TXT.
33
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
44

5-
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
6-
message(WARNING "The benchmarks SHOULD NOT be run in the Debug build type!")
5+
# In MSVC builds, there is no way to determine the actual build type during the
6+
# CMake configuration step. Therefore, this message is printed in all MSVC
7+
# builds.
8+
if(WINDOWS OR NOT CMAKE_BUILD_TYPE STREQUAL "Release")
9+
message(
10+
STATUS
11+
"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!"
12+
)
713
endif()
814

915
if(UMF_BUILD_BENCHMARKS_MT)

test/test_installation.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,7 @@ def _create_match_list(self) -> List[str]:
6767
lib_prefix = "lib"
6868

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

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

0 commit comments

Comments
 (0)