Skip to content

Commit

Permalink
Merge pull request #286 from aminya/msvc-toolchain [skip ci]
Browse files Browse the repository at this point in the history
  • Loading branch information
aminya authored Oct 23, 2024
2 parents b721800 + d58a7b6 commit e63a5d9
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
8 changes: 0 additions & 8 deletions src/Index.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,6 @@ include("${ProjectOptions_SRC_DIR}/DetectCompiler.cmake")
include("${ProjectOptions_SRC_DIR}/CrossCompiler.cmake")
include("${ProjectOptions_SRC_DIR}/DynamicProjectOptions.cmake")
include("${ProjectOptions_SRC_DIR}/Hardening.cmake")

# Include msvc toolchain on windows if the generator is not visual studio. Should be called before run_vcpkg and run_conan to be effective
if("${CMAKE_TOOLCHAIN_FILE}" STREQUAL "")
msvc_toolchain()
else()
message(STATUS "project_options: skipping msvc_toolchain as CMAKE_TOOLCHAIN_FILE is set")
endif()

include("${ProjectOptions_SRC_DIR}/Conan.cmake")
include("${ProjectOptions_SRC_DIR}/Vcpkg.cmake")

Expand Down
16 changes: 15 additions & 1 deletion src/VCEnvironment.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,21 @@ function(is_msvc value)
set(${value} OFF PARENT_SCOPE)
endfunction()

# Include msvc toolchain on windows if the generator is not visual studio. Should be called before run_vcpkg and run_conan to be effective
#[[.rst:

``msvc_toolchain``
===============

Include msvc toolchain on windows if the generator is not visual studio. Should be called before run_vcpkg and run_conan to be effective

Notes: if running in a cross-compilation situation, the toolchain might not work as expected. So add proper if-checks if you have such a configuration

.. code:: cmake

msvc_toolchain()
# should be included before run_vcpkg/run_conan to be effective

]]
macro(msvc_toolchain)
if(# if on windows and the generator is not Visual Studio
WIN32 AND NOT CMAKE_GENERATOR MATCHES "Visual Studio*"
Expand Down

0 comments on commit e63a5d9

Please sign in to comment.