Revision: 75989
http://sourceforge.net/p/brlcad/code/75989
Author: starseeker
Date: 2020-05-31 15:36:22 +0000 (Sun, 31 May 2020)
Log Message:
-----------
Rework the 3dm-g conversion build target to use generator expressions rather
than the CURRENT_PATH mechanism.
Modified Paths:
--------------
brlcad/trunk/db/CMakeLists.txt
brlcad/trunk/misc/CMake/BRLCAD_Util.cmake
Added Paths:
-----------
brlcad/trunk/db/conv_run.cmake.in
Modified: brlcad/trunk/db/CMakeLists.txt
===================================================================
--- brlcad/trunk/db/CMakeLists.txt 2020-05-31 14:43:14 UTC (rev 75988)
+++ brlcad/trunk/db/CMakeLists.txt 2020-05-31 15:36:22 UTC (rev 75989)
@@ -53,21 +53,15 @@
# the sense that it uses libgcv...)
if(${MODEL_TYPE} STREQUAL "3dm")
- # Because we won't know the output directory in the script reliably until
run time,
- # we append CURRENT_BUILD_DIR as a string to the arguments - it is the
script's
- # responsibility to handle it correctly at run time.
- set(CMD_ARGS "-o" "CURRENT_BUILD_DIR/${output_file}"
"${CMAKE_CURRENT_SOURCE_DIR}/${in_model}")
-
+ set(INPUT_FILE "${CMAKE_CURRENT_SOURCE_DIR}/${in_model}")
+ set(OUTPUT_FILE "${output_file}")
# Use the model name for the script, since the output file is specific to
this input
- set(script_file "${CMAKE_CURRENT_BINARY_DIR}/${in_model_root}.cmake")
+ configure_file("${CMAKE_SOURCE_DIR}/db/conv_run.cmake.in"
"${CMAKE_CURRENT_BINARY_DIR}/${in_model_root}.cmake" @ONLY)
- # We know enough - write the script
- generate_cmd_script(3dm-g "${script_file}" OLOG "${log_file}" ELOG
"${log_file}" CARGS "${CMD_ARGS}")
-
# Define the target
add_custom_command(
OUTPUT ${CMAKE_CURRENT_BUILD_DIR_SCRIPT}/${output_file}
- COMMAND ${CMAKE_COMMAND} -P "${script_file}"
+ COMMAND ${CMAKE_COMMAND} -DEXEC=$<TARGET_FILE:3dm-g> -P
"${CMAKE_CURRENT_BINARY_DIR}/${in_model_root}.cmake"
DEPENDS 3dm-g ${CMAKE_CURRENT_SOURCE_DIR}/${in_model}
)
Added: brlcad/trunk/db/conv_run.cmake.in
===================================================================
--- brlcad/trunk/db/conv_run.cmake.in (rev 0)
+++ brlcad/trunk/db/conv_run.cmake.in 2020-05-31 15:36:22 UTC (rev 75989)
@@ -0,0 +1,41 @@
+string(REPLACE "\\" "" GCV_EXEC "${EXEC}")
+set(INPUT_FILE "@INPUT_FILE@")
+set(OUTPUT_FILE "@OUTPUT_FILE@")
+
+# NOTE: OUTPUT_FILE needs to be defined in terms of a path relative to the root
+# of the build diretory, not as an absolute path. Since that root may change
+# at runtime in multiconfig builds, the full output path cannot be encoded
+# directly into the generated script.
+get_filename_component(OF_ABS "${OUTPUT_FILE}" ABSOLUTE)
+if ("${OF_ABS}" STREQUAL "${OUTPUT_FILE}")
+ message(FATAL_ERROR "Absoute output file path \"${OUTPUT_FILE}\" supplied
for conversion of \"${INPUT_FILE}\" - path must be relative.")
+endif ("${OF_ABS}" STREQUAL "${OUTPUT_FILE}")
+
+# Because the build directory changes at runtime in multiconfig builds, we
+# need to deduce its current value from GCV_EXEC.
+# TODO - this breaks if the bin directory is more than one deep...
+get_filename_component(CBDIR "${GCV_EXEC}" DIRECTORY)
+get_filename_component(CROOT "${CBDIR}" DIRECTORY)
+
+# BRLCAD_ROOT is the hammer that makes certain we are running
+# things found in the build directory.
+set(ENV{BRLCAD_ROOT} "${CROOT}")
+
+# Now that we know the root, finalize the full path output file location
+set(OUTPUT_FILE "${CROOT}/${OUTPUT_FILE}")
+
+execute_process(
+ COMMAND "${GCV_EXEC}" -o "${OUTPUT_FILE}" "${INPUT_FILE}"
+ RESULT_VARIABLE conv_result OUTPUT_VARIABLE conv_log ERROR_VARIABLE conv_log
+ )
+
+if(conv_result)
+ message(FATAL_ERROR "[geometry conversion] Failure:
${conv_result}\n${GCV_EXEC} -o \"${OUTPUT_FILE}\"
\"${INPUT_FILE}\"\n\n${conv_log}")
+endif(conv_result)
+
+# Local Variables:
+# tab-width: 8
+# mode: cmake
+# indent-tabs-mode: t
+# End:
+# ex: shiftwidth=2 tabstop=8
Property changes on: brlcad/trunk/db/conv_run.cmake.in
___________________________________________________________________
Added: svn:eol-style
## -0,0 +1 ##
+native
\ No newline at end of property
Added: svn:executable
## -0,0 +1 ##
+*
\ No newline at end of property
Added: svn:mime-type
## -0,0 +1 ##
+text/plain
\ No newline at end of property
Modified: brlcad/trunk/misc/CMake/BRLCAD_Util.cmake
===================================================================
--- brlcad/trunk/misc/CMake/BRLCAD_Util.cmake 2020-05-31 14:43:14 UTC (rev
75988)
+++ brlcad/trunk/misc/CMake/BRLCAD_Util.cmake 2020-05-31 15:36:22 UTC (rev
75989)
@@ -438,63 +438,6 @@
endfunction(ADD_TARGET_DEPS tname)
#---------------------------------------------------------------------------
-# Write out an execution script to run commands with the necessary
-# variables set to allow execution in the build directory, even if
-# there are installed libraries present in the final installation
-# directory.
-function(generate_cmd_script cmd_exe script_file)
-
- cmake_parse_arguments(GCS "" "OLOG;ELOG" "CARGS" ${ARGN})
-
- # Initialize file
- file(WRITE "${script_file}" "# Script to run ${cmd_exe}\n")
-
- # Handle multiconfig (must be run-time determination for Visual Studio and
XCode)
- # TODO - logic writing this trick needs to become some sort of standard
routine...
- file(APPEND "${script_file}" "if(EXISTS
\"${CMAKE_BINARY_DIR}/CMakeTmp/CURRENT_PATH/Release\")\n")
- file(APPEND "${script_file}" " set(CBDIR
\"${CMAKE_BINARY_DIR}/Release\")\n")
- file(APPEND "${script_file}" "elseif(EXISTS
\"${CMAKE_BINARY_DIR}/CMakeTmp/CURRENT_PATH/Debug\")\n")
- file(APPEND "${script_file}" " set(CBDIR \"${CMAKE_BINARY_DIR}/Debug\")\n")
- file(APPEND "${script_file}" "else(EXISTS
\"${CMAKE_BINARY_DIR}/CMakeTmp/CURRENT_PATH/Release\")\n")
- file(APPEND "${script_file}" " set(CBDIR \"${CMAKE_BINARY_DIR}\")\n")
- file(APPEND "${script_file}" "endif(EXISTS
\"${CMAKE_BINARY_DIR}/CMakeTmp/CURRENT_PATH/Release\")\n")
-
- # BRLCAD_ROOT is the hammer that makes certain we are running
- # things found in the build directory
- file(APPEND "${script_file}" "set(ENV{BRLCAD_ROOT} \"\${CBDIR}\")\n")
-
- # Substitute in the correct binary path anywhere it is needed in the args
- file(APPEND "${script_file}" "string(REPLACE \"CURRENT_BUILD_DIR\"
\"\${CBDIR}\" FIXED_CMD_ARGS \"${GCS_CARGS}\")\n")
-
- # Use the CMake executable to figure out if we need an extension
- get_filename_component(EXE_EXT "${CMAKE_COMMAND}" EXT)
-
- # Write the actual cmake command to run the process
- file(APPEND "${script_file}" "execute_process(COMMAND
\"\${CBDIR}/${BIN_DIR}/${cmd_exe}${EXE_EXT}\" \${FIXED_CMD_ARGS}
RESULT_VARIABLE CR OUTPUT_VARIABLE CO ERROR_VARIABLE CE)\n")
-
- # Log the outputs, if we are supposed to do that
- if(GCS_OLOG)
- file(APPEND "${script_file}" "file(APPEND \"${GCS_OLOG}\" \"\${CO}\")\n")
- endif(GCS_OLOG)
- if(GCS_ELOG)
- file(APPEND "${script_file}" "file(APPEND \"${GCS_ELOG}\" \"\${CE}\")\n")
- endif(GCS_ELOG)
-
- # Fail the command if the result was non-zero
- file(APPEND "${script_file}" "if(CR)\n")
- file(APPEND "${script_file}" " message(FATAL_ERROR
\"\${CBDIR}/${BIN_DIR}/${cmd_exe}${EXE_EXT} failure:
\${CR}\\n\${CO}\\n\${CE}\")\n")
- file(APPEND "${script_file}" "endif(CR)\n")
-
- # If we are doing distclean, let CMake know to remove the script and log
files
- if(COMMAND distclean)
- set(distclean_files "${script_file}" "${GCS_OLOG}" "${GCS_ELOG}")
- list(REMOVE_DUPLICATES distclean_files)
- distclean(${distclean_files})
- endif(COMMAND distclean)
-
-endfunction(generate_cmd_script)
-
-#---------------------------------------------------------------------------
# Set variables reporting time of configuration. Sets CONFIG_DATE and
# CONFIG_DATESTAMP in parent scope.
#
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