Skip to content

Commit 2cef40d

Browse files
committed
Refactor
1 parent 3af47b3 commit 2cef40d

File tree

2 files changed

+26
-16
lines changed

2 files changed

+26
-16
lines changed

CMakeLists.txt

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,21 +66,11 @@ set(NBL_BUILTIN_RESOURCES_DIRECTORY_PATH "${NBL_ROOT_PATH}/include/nbl/builtin")
6666
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${NBL_ROOT_PATH}/cmake" CACHE PATH "")
6767
get_property(NBL_IS_MULTI_CONFIG GLOBAL PROPERTY GENERATOR_IS_MULTI_CONFIG)
6868

69+
include(common)
6970
#import .vsconfig file with VS components required for Nabla
70-
if(WIN32 AND MSVC)
71-
option(NBL_IMPORT_VS_CONFIG "" ON)
72-
73-
if(NBL_IMPORT_VS_CONFIG)
74-
message(STATUS "NOTICE: Configuration will continue after Visual Studio Installer is closed.")
75-
message(STATUS "To disable VS config import uncheck the NBL_IMPORT_VS_CONFIG option.")
76-
set(DEVENV_ISOLATION_INI_PATH "${CMAKE_GENERATOR_INSTANCE}/Common7/IDE/devenv.isolation.ini")
77-
file(READ ${DEVENV_ISOLATION_INI_PATH} DEVENV_ISOLATION_INI_CONTENT)
78-
string(REGEX MATCH "SetupEngineFilePath=\"([^\"]*)\"" _match "${DEVENV_ISOLATION_INI_CONTENT}")
79-
string(REPLACE "/" "\\" NBL_VS_INSTALLATION_PATH ${CMAKE_GENERATOR_INSTANCE})
80-
set(VS_INSTALLER_PATH "${CMAKE_MATCH_1}")
81-
82-
execute_process(COMMAND "${VS_INSTALLER_PATH}" modify --installPath "${NBL_VS_INSTALLATION_PATH}" --config "${NBL_ROOT_PATH}/.vsconfig" --allowUnsignedExtensions)
83-
endif()
71+
if(WIN32 AND "${CMAKE_GENERATOR}" MATCHES "Visual Studio")
72+
option(NBL_ENABLE_VS_CONFIG_IMPORT "" OFF)
73+
NBL_IMPORT_VS_CONFIG()
8474
endif()
8575

8676
# Configure CCache if available
@@ -206,7 +196,6 @@ get_filename_component(NBL_MEDIA_DIRECTORY_ABS "${NBL_MEDIA_DIRECTORY}" ABSOLUTE
206196

207197
include(submodules/update)
208198
find_package(Python3 COMPONENTS Interpreter REQUIRED)
209-
include(common)
210199

211200
add_subdirectory(${THIRD_PARTY_SOURCE_DIR})
212201

cmake/common.cmake

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,4 +1298,25 @@ macro(NBL_GET_ALL_TARGETS_RECURSIVE NBL_TARGETS NBL_DIRECTORY)
12981298

12991299
get_property(NBL_GATHERED_TARGETS DIRECTORY ${NBL_DIRECTORY} PROPERTY BUILDSYSTEM_TARGETS)
13001300
list(APPEND ${NBL_TARGETS} ${NBL_GATHERED_TARGETS})
1301-
endmacro()
1301+
endmacro()
1302+
1303+
function(NBL_IMPORT_VS_CONFIG)
1304+
if(NBL_ENABLE_VS_CONFIG_IMPORT)
1305+
message(STATUS "NOTICE: Configuration will continue after Visual Studio Installer is closed.")
1306+
message(STATUS "To disable VS config import disable the NBL_IMPORT_VS_CONFIG option.")
1307+
set(NBL_DEVENV_ISOLATION_INI_PATH "${CMAKE_GENERATOR_INSTANCE}/Common7/IDE/devenv.isolation.ini")
1308+
file(READ ${NBL_DEVENV_ISOLATION_INI_PATH} NBL_DEVENV_ISOLATION_INI_CONTENT)
1309+
string(REPLACE "/" "\\" NBL_VS_INSTALLATION_PATH ${CMAKE_GENERATOR_INSTANCE})
1310+
string(REGEX MATCH "SetupEngineFilePath=\"([^\"]*)\"" _match "${NBL_DEVENV_ISOLATION_INI_CONTENT}")
1311+
set(NBL_VS_INSTALLER_PATH "${CMAKE_MATCH_1}")
1312+
1313+
execute_process(COMMAND "${NBL_VS_INSTALLER_PATH}" modify --installPath "${NBL_VS_INSTALLATION_PATH}" --config "${NBL_ROOT_PATH}/.vsconfig" --allowUnsignedExtensions
1314+
ERROR_VARIABLE vsconfig_error
1315+
RESULT_VARIABLE vsconfig_result)
1316+
1317+
if(NOT vsconfig_result EQUAL 0)
1318+
message(FATAL_ERROR "Visual Studio Installer error: ${vsconfig_error}")
1319+
endif()
1320+
1321+
endif()
1322+
endfunction()

0 commit comments

Comments
 (0)