Skip to content

Commit bf78dab

Browse files
committed
- Adding a CMake utility function to setup debugger environments so that the debugger can locate the run-time dependencies. This makes it possible to compile and launch the projects directly within visual studio for example.
- Calling the above function in projects that need it. Signed-off-by: cuneyt.ozdas <cuneyt.ozdas@autodesk.com>
1 parent 9bb1455 commit bf78dab

14 files changed

Lines changed: 89 additions & 9 deletions

File tree

CMakeLists.txt

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,11 @@ endif()
349349

350350
include(CompilerFlags)
351351

352+
###############################################################################
353+
# Include utility functions for setting debugging environments
354+
355+
include(DebuggerEnvironment)
356+
352357
###############################################################################
353358
# External linking options
354359

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# SPDX-License-Identifier: BSD-3-Clause
2+
# Copyright Contributors to the OpenColorIO Project.
3+
4+
5+
###############################################################################
6+
# Define a function to set debugger environment so that the run time
7+
# dependencies can be located by the debugger.
8+
9+
function(set_debugger_env target_name)
10+
cmake_parse_arguments(ARG "NEEDS_GL" "" "" ${ARGN})
11+
12+
if(NOT TARGET ${target_name})
13+
message(FATAL_ERROR "set_debugger_env: '${target_name}' is not a CMake target")
14+
endif()
15+
16+
# Set the Paths for Visual Studio IDE Debugger.
17+
if(MSVC)
18+
if(OCIO_GL_ENABLED AND ARG_NEEDS_GL)
19+
# Add folders for glut and glew DLLs.
20+
set(extra_dirs "${GLUT_INCLUDE_DIR}/../bin;${GLEW_INCLUDE_DIRS}/../bin")
21+
endif()
22+
23+
set_property(TARGET ${target_name} PROPERTY
24+
VS_DEBUGGER_ENVIRONMENT "PATH=$<JOIN:$<TARGET_RUNTIME_DLL_DIRS:${target_name}>,;>;${extra_dirs};%PATH%"
25+
)
26+
endif()
27+
endfunction()

src/apps/ocioarchive/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,7 @@ ocio_strip_binary(ocioarchive)
3030
install(TARGETS ocioarchive
3131
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3232
)
33+
34+
# Set the debugger environment so that the executable can be launched
35+
# directly within IDE (e.g. Visual Studio).
36+
set_debugger_env(ocioarchive)

src/apps/ociobakelut/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,7 @@ ocio_strip_binary(ociobakelut)
3939
install(TARGETS ociobakelut
4040
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
4141
)
42+
43+
# Set the debugger environment so that the executable can be launched
44+
# directly within IDE (e.g. Visual Studio).
45+
set_debugger_env(ociobakelut)

src/apps/ociocheck/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,7 @@ ocio_strip_binary(ociocheck)
2828
install(TARGETS ociocheck
2929
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3030
)
31+
32+
# Set the debugger environment so that the executable can be launched
33+
# directly within IDE (e.g. Visual Studio).
34+
set_debugger_env(ociocheck)

src/apps/ociochecklut/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,3 +36,7 @@ ocio_strip_binary(ociochecklut)
3636
install(TARGETS ociochecklut
3737
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3838
)
39+
40+
# Set the debugger environment so that the executable can be launched
41+
# directly within IDE (e.g. Visual Studio).
42+
set_debugger_env(ociochecklut NEEDS_GL)

src/apps/ocioconvert/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,7 @@ ocio_strip_binary(ocioconvert)
4040
install(TARGETS ocioconvert
4141
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
4242
)
43+
44+
# Set the debugger environment so that the executable can be launched
45+
# directly within IDE (e.g. Visual Studio).
46+
set_debugger_env(ocioconvert NEEDS_GL)

src/apps/ociodisplay/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,3 +53,7 @@ ocio_strip_binary(ociodisplay)
5353
install(TARGETS ociodisplay
5454
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
5555
)
56+
57+
# Set the debugger environment so that the executable can be launched
58+
# directly within IDE (e.g. Visual Studio).
59+
set_debugger_env(ociodisplay NEEDS_GL)

src/apps/ociolutimage/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,7 @@ ocio_strip_binary(ociolutimage)
3333
install(TARGETS ociolutimage
3434
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3535
)
36+
37+
# Set the debugger environment so that the executable can be launched
38+
# directly within IDE (e.g. Visual Studio).
39+
set_debugger_env(ociolutimage)

src/apps/ociomakeclf/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,3 +29,7 @@ ocio_strip_binary(ociomakeclf)
2929
install(TARGETS ociomakeclf
3030
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
3131
)
32+
33+
# Set the debugger environment so that the executable can be launched
34+
# directly within IDE (e.g. Visual Studio).
35+
set_debugger_env(ociomakeclf)

0 commit comments

Comments
 (0)