Revision: 77667
http://sourceforge.net/p/brlcad/code/77667
Author: starseeker
Date: 2020-11-02 23:55:12 +0000 (Mon, 02 Nov 2020)
Log Message:
-----------
Start working on generating a cmake script that can set these environment
variables, rather than trying to run the bat file directly - the bat file may
return non-zero even though it works for what we need, which needlessly breaks
builds...
Modified Paths:
--------------
brlcad/branches/extbuild/src/other/ext/CMakeLists.txt
Modified: brlcad/branches/extbuild/src/other/ext/CMakeLists.txt
===================================================================
--- brlcad/branches/extbuild/src/other/ext/CMakeLists.txt 2020-11-02
22:07:14 UTC (rev 77666)
+++ brlcad/branches/extbuild/src/other/ext/CMakeLists.txt 2020-11-02
23:55:12 UTC (rev 77667)
@@ -213,6 +213,7 @@
# With MSVC, some of the non-CMake subbuilds are going to need the vcvars bat
# file to set up the environment.
if(MSVC)
+
get_filename_component(COMPILER_DIR "${CMAKE_C_COMPILER}" DIRECTORY)
get_filename_component(COMPILER_ROOT "${COMPILER_DIR}" NAME)
set(VCVARS_BAT "${COMPILER_DIR}/vcvars${COMPILER_ROOT}.bat")
@@ -232,6 +233,34 @@
message(FATAL_ERROR "Could not find vcvars bat file in ${COMPILER_DIR}")
endif(NOT EXISTS "${VCVARS_BAT}")
endif(NOT EXISTS "${VCVARS_BAT}")
+
+
+ # Collect the dev env info. The VCVARS bat file may not exit without error,
+ # even if it produces a working build environment. To deal with this, we
+ # create a CMake script that sets up the environment and runs a user
+ # supplied command.
+ execute_process(
+ COMMAND "${VCVARS_BAT}" && set
+ OUTPUT_FILE vcvars.txt
+ )
+
+ # Eliminate backslashes on the end of lines for file(STRINGS)
+ file(READ vcvars.txt vcvars)
+ string(REPLACE "\\\n" "\n" nvcvars "${vcvars}")
+ file(WRITE vcvars.txt "${nvcvars}")
+
+ # Stage file
+ file(WRITE "${CMAKE_BINARY_DIR}/win_exec.cmake" "# Set Visual Studio
environment vars and run programs")
+
+ # Extract environment key/value pairs
+ file(STRINGS vcvars.txt vlines)
+ foreach(line IN LISTS vlines)
+ if (line MATCHES "^([a-zA-Z0-9_-]+)=(.*)$")
+ file(APPEND "${CMAKE_BINARY_DIR}/win_exec.cmake"
"set(ENV{${CMAKE_MATCH_1}} \"${CMAKE_MATCH_2}\")\n")
+ endif()
+ endforeach()
+ file(APPEND "${CMAKE_BINARY_DIR}/win_exec.cmake" "execute_process(COMMAND
\${CMD})\n")
+
endif(MSVC)
# TODO - need to set these based on the feature flags...
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits