Spaces:
Running
on
Zero
Running
on
Zero
File size: 5,890 Bytes
5f9d349 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 |
# Copyright (C) 2020, Inria
# GRAPHDECO research group, https://team.inria.fr/graphdeco
# All rights reserved.
#
# This software is free for non-commercial, research and evaluation use
# under the terms of the LICENSE.md file.
#
# For inquiries contact [email protected] and/or [email protected]
if(__MSVCsetUserCommand_cmake_INCLUDED__)
return()
else()
set(__MSVCsetUserCommand_cmake_INCLUDED__ ON)
endif()
## Allow to configure the Debugger settings of visual studio
## Note: Using this command under linux doesn't affect anything
## On run Debug Windows local : visual will try to load a specific COMMAND with ARGS in the provided WORKING_DIR
##
## usage:
## MSVCsetUserCommand( <targetName>
## [COMMAND <myCustomAppToLaunch> | [ PATH <myCustomDirWhereIsDefaultTargetFileNameToLaunch> [FILE <myCustomExecFileToLaunch>] ] ]
## ARGS <associatedArguments>
## WORKING_DIR <whereStartTheProgram>
## )
##
## Warning 1 : All arugments () must be passed under quotes
## Warning 2 : WORKING_DIR path arg have to finish with remain slah '/'
## Warning 3 : use COMMAND for external app OR PATH (optionaly with FILE) option(s) to set your built/installed/moved target
##
## Example 1:
## include(MSVCsetUserCommand)
## MSVCsetUserCommand( UnityRenderingPlugin
## COMMAND "C:/Program Files (x86)/Unity/Editor/Unity.exe"
## ARGS "-force-opengl -projectPath \"${CMAKE_HOME_DIRECTORY}/UnityPlugins/RenderingPluginExample/UnityProject\""
## WORKING_DIR "${CMAKE_HOME_DIRECTORY}/UnityPlugins/RenderingPluginExample/UnityProject"
## VERBOSE
## )
##
## Example 2:
## include(MSVCsetUserCommand)
## MSVCsetUserCommand( ibrApp
## PATH "C:/Program Files (x86)/workspace/IBR/install"
## FILE "ibrApp${CMAKE_EXECUTABLE_SUFFIX}" ## this option line is optional since the target name didn't change between build and install step
## ARGS "-path \"${CMAKE_HOME_DIRECTORY}/dataset\""
## WORKING_DIR "${CMAKE_HOME_DIRECTORY}"
## VERBOSE
## )
##
function(MSVCsetUserCommand targetName)
cmake_parse_arguments(MSVCsuc "VERBOSE" "PATH;FILE;COMMAND;ARGS;WORKING_DIR" "" ${ARGN} )
## If no arguments are given, do not create an unecessary .vcxproj.user file
set(MSVCsuc_DEFAULT OFF)
if(MSVCsuc_PATH AND MSVCsuc_DEFAULT)
set(MSVCsuc_DEFAULT OFF)
endif()
if(MSVCsuc_FILE AND MSVCsuc_DEFAULT)
set(MSVCsuc_DEFAULT OFF)
endif()
if(NOT MSVCsuc_COMMAND)
if(MSVCsuc_PATH AND MSVCsuc_FILE)
set(MSVCsuc_COMMAND "${MSVCsuc_PATH}\\${MSVCsuc_FILE}")
elseif(MSVCsuc_PATH)
set(MSVCsuc_COMMAND "${MSVCsuc_PATH}\\$(TargetFileName)")
else()
set(MSVCsuc_COMMAND "$(TargetPath)") ## => $(TargetDir)\$(TargetName)$(TargetExt)
endif()
elseif(MSVCsuc_DEFAULT)
set(MSVCsuc_DEFAULT OFF)
endif()
# NOTE: there was a typo here. there is an else if written after else statement
# changing the order of the else if statement
if(MSVCsuc_WORKING_DIR)
file(TO_NATIVE_PATH ${MSVCsuc_WORKING_DIR} MSVCsuc_WORKING_DIR)
elseif(MSVCsuc_DEFAULT)
set(MSVCsuc_DEFAULT OFF)
else()
set(MSVCsuc_WORKING_DIR "$(ProjectDir)")
endif()
if(NOT MSVCsuc_ARGS)
set(MSVCsuc_ARGS "")
elseif(MSVCsuc_DEFAULT)
set(MSVCsuc_DEFAULT OFF)
endif()
if(MSVC10 OR (MSVC AND MSVC_VERSION GREATER 1600)) # 2010 or newer
if(CMAKE_SIZEOF_VOID_P EQUAL 8)
set(PLATEFORM_BITS x64)
else()
set(PLATEFORM_BITS Win32)
endif()
if(NOT MSVCsuc_DEFAULT AND PLATEFORM_BITS)
file(WRITE "${CMAKE_CURRENT_BINARY_DIR}/${targetName}.vcxproj.user"
"<?xml version=\"1.0\" encoding=\"utf-8\"?>
<Project ToolsVersion=\"4.0\" xmlns=\"http://schemas.microsoft.com/developer/msbuild/2003\">
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Release|${PLATEFORM_BITS}'\">
<LocalDebuggerCommand>${MSVCsuc_COMMAND}</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>${MSVCsuc_ARGS}</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>${MSVCsuc_WORKING_DIR}</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='Debug|${PLATEFORM_BITS}'\">
<LocalDebuggerCommand>${MSVCsuc_COMMAND}</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>${MSVCsuc_ARGS}</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>${MSVCsuc_WORKING_DIR}</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='MinSizeRel|${PLATEFORM_BITS}'\">
<LocalDebuggerCommand>${MSVCsuc_COMMAND}</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>${MSVCsuc_ARGS}</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>${MSVCsuc_WORKING_DIR}</LocalDebuggerWorkingDirectory>
</PropertyGroup>
<PropertyGroup Condition=\"'$(Configuration)|$(Platform)'=='RelWithDebInfo|${PLATEFORM_BITS}'\">
<LocalDebuggerCommand>${MSVCsuc_COMMAND}</LocalDebuggerCommand>
<LocalDebuggerCommandArguments>${MSVCsuc_ARGS}</LocalDebuggerCommandArguments>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerWorkingDirectory>${MSVCsuc_WORKING_DIR}</LocalDebuggerWorkingDirectory>
</PropertyGroup>
</Project>"
)
if(MSVCsuc_VERBOSE)
message(STATUS "[MSVCsetUserCommand] Write ${CMAKE_CURRENT_BINARY_DIR}/${targetName}.vcxproj.user file")
message(STATUS " to execute ${MSVCsuc_COMMAND} ${MSVCsuc_ARGS}")
message(STATUS " from derectory ${MSVCsuc_WORKING_DIR}")
message(STATUS " on visual studio run debugger button")
endif()
else()
message(WARNING "PLATEFORM_BITS is undefined...")
endif()
else()
if(MSVCsuc_VERBOSE)
message(WARNING "MSVCsetUserCommand is disable because too old MSVC is used (need MSVC10 2010 or newer)")
endif()
endif()
endfunction()
|