Skip to content

Commit 7d2a12a

Browse files
Add check to CMakeList for check versions and path order on windows (OrcaSlicer#9390)
* chore: limit cmake version to 3.31 for win32 * chore: fix check for variable path order * chore: fix check for pipeline * chore: remove warn on CI enviroment * chore: change cmake limit version from 3.32 to 4.0
1 parent addade1 commit 7d2a12a

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

CMakeLists.txt

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,50 @@
11
cmake_minimum_required(VERSION 3.13)
22

3+
# Verify that your CMake version is exactly 3.31.x series or lower on windows
4+
if(${CMAKE_VERSION} VERSION_LESS "3.13" OR ${CMAKE_VERSION} VERSION_GREATER_EQUAL "4.0")
5+
message(FATAL_ERROR "Only CMake versions between 3.13.x and 3.31.x is supported. Detected version: ${CMAKE_VERSION}")
6+
endif()
7+
8+
if (WIN32)
9+
# Detect known CI environments
10+
set(IS_CI FALSE)
11+
if(DEFINED ENV{CI})
12+
set(IS_CI TRUE)
13+
elseif(DEFINED ENV{GITHUB_ACTIONS})
14+
set(IS_CI TRUE)
15+
elseif(DEFINED ENV{GITLAB_CI})
16+
set(IS_CI TRUE)
17+
elseif(DEFINED ENV{TF_BUILD})
18+
set(IS_CI TRUE)
19+
elseif(DEFINED ENV{BUILD_NUMBER}) # Jenkins
20+
set(IS_CI TRUE)
21+
endif()
22+
23+
# Detect common misconfiguration (Strawberry Perl in PATH before CMake)
24+
# We use ENV to check the PATH order
25+
string(REPLACE "\\" "/" ENV_PATH "$ENV{PATH}")
26+
string(FIND "${ENV_PATH}" "Strawberry/c/bin" STRAWBERRY_POS)
27+
string(FIND "${ENV_PATH}" "Program Files/CMake/bin" CMAKE_POS)
28+
29+
if (STRAWBERRY_POS GREATER -1 AND CMAKE_POS GREATER -1 AND STRAWBERRY_POS LESS CMAKE_POS)
30+
set(_warning_text "
31+
#############################################################
32+
Detected Strawberry Perl's 'c/bin' appearing before CMake in PATH.
33+
This is known to cause CMake to misbehave (e.g., missing modules).
34+
Please adjust your PATH so that:
35+
C:\\Program Files\\CMake\\bin
36+
appears before:
37+
C:\\Strawberry\\c\\bin
38+
You can do this in Environment Variables settings.
39+
#############################################################
40+
")
41+
42+
if(NOT IS_CI)
43+
message(FATAL_ERROR "${_warning_text}")
44+
endif()
45+
endif()
46+
endif ()
47+
348
if (APPLE)
449
# if CMAKE_OSX_DEPLOYMENT_TARGET is not set, set it to 11.3
550
if (NOT CMAKE_OSX_DEPLOYMENT_TARGET)

0 commit comments

Comments
 (0)