Skip to content

Commit

Permalink
build: set MSVC-related cmake policies to new
Browse files Browse the repository at this point in the history
Setting cmake policies CMP0091 and CMP0092 to new are much essential for
smooth building with MSVC.

CMP0091 sets the runtime flags in a consistent, defined manner. This is
extremely important as you can't use two different runtime libraries on
MSVC and will lead to build failure.

CMP0092 makes it possible to set the warning level. For dependencies we
completely silence all warnings.

More information on these policies:
https://cmake.org/cmake/help/latest/policy/CMP0091.html
https://cmake.org/cmake/help/latest/policy/CMP0092.html
  • Loading branch information
dundargoc committed Apr 27, 2024
1 parent 158e329 commit f384ba5
Show file tree
Hide file tree
Showing 8 changed files with 11 additions and 25 deletions.
3 changes: 3 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@
cmake_minimum_required(VERSION 3.13)

# Can be removed once minimum version is at least 3.15
if(POLICY CMP0091)
cmake_policy(SET CMP0091 NEW)
endif()
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
Expand Down
5 changes: 0 additions & 5 deletions cmake.deps/cmake/GettextCMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
cmake_minimum_required(VERSION 3.13)

# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(gettext C)

add_compile_options(-w)
Expand Down
4 changes: 0 additions & 4 deletions cmake.deps/cmake/LibiconvCMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
cmake_minimum_required(VERSION 3.13)
# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(libiconv C)

add_compile_options(-w)
Expand Down
4 changes: 0 additions & 4 deletions cmake.deps/cmake/LibvtermCMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
cmake_minimum_required(VERSION 3.13)
# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(libvterm C)

add_compile_options(-w)
Expand Down
4 changes: 0 additions & 4 deletions cmake.deps/cmake/MarkdownParserCMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
cmake_minimum_required(VERSION 3.13)
# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(${PARSERLANG} C)

add_compile_options(-w)
Expand Down
4 changes: 0 additions & 4 deletions cmake.deps/cmake/TreesitterCMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
cmake_minimum_required(VERSION 3.13)
# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(treesitter C)

add_compile_options(-w)
Expand Down
4 changes: 0 additions & 4 deletions cmake.deps/cmake/TreesitterParserCMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,4 @@
cmake_minimum_required(VERSION 3.13)
# Can be removed once minimum version is at least 3.15
if(POLICY CMP0092)
cmake_policy(SET CMP0092 NEW)
endif()
project(parser C)

add_compile_options(-w)
Expand Down
8 changes: 8 additions & 0 deletions cmake/Deps.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ if(APPLE)
list(APPEND DEPS_CMAKE_ARGS -D CMAKE_FIND_FRAMEWORK=${CMAKE_FIND_FRAMEWORK})
endif()

# Can be removed once minimum version is at least 3.15
if(POLICY CMP0091)
list(APPEND -D CMAKE_POLICY_DEFAULT_CMP0091=NEW)
endif()
if(POLICY CMP0092)
list(APPEND -D CMAKE_POLICY_DEFAULT_CMP0092=NEW)
endif()

# MAKE_PRG
if(UNIX)
find_program(MAKE_PRG NAMES gmake make)
Expand Down

0 comments on commit f384ba5

Please sign in to comment.