Skip to content
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,11 @@ endif()

include(CompilerFlags)

###############################################################################
# Include utility functions for setting debugging environments

include(DebuggerEnvironment)

###############################################################################
# External linking options

Expand Down
27 changes: 27 additions & 0 deletions share/cmake/utils/DebuggerEnvironment.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
# SPDX-License-Identifier: BSD-3-Clause
# Copyright Contributors to the OpenColorIO Project.


###############################################################################
# Define a function to set debugger environment so that the run time
# dependencies can be located by the debugger.

function(set_debugger_env target_name)
cmake_parse_arguments(ARG "NEEDS_GL" "" "" ${ARGN})

if(NOT TARGET ${target_name})
message(FATAL_ERROR "set_debugger_env: '${target_name}' is not a CMake target")
endif()

# Set the Paths for Visual Studio IDE Debugger.
if(MSVC)
if(OCIO_GL_ENABLED AND ARG_NEEDS_GL)
# Add folders for glut and glew DLLs.
set(extra_dirs "${GLUT_INCLUDE_DIR}/../bin;${GLEW_INCLUDE_DIRS}/../bin")
endif()

set_property(TARGET ${target_name} PROPERTY
VS_DEBUGGER_ENVIRONMENT "PATH=$<JOIN:$<TARGET_RUNTIME_DLL_DIRS:${target_name}>,;>;${extra_dirs};%PATH%"
)
endif()
endfunction()
3 changes: 3 additions & 0 deletions src/OpenColorIO/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,9 @@ configure_file(CPUInfoConfig.h.in CPUInfoConfig.h)

add_library(OpenColorIO ${SOURCES})

# Group the source files to replicate the source tree structure in the IDEs.
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" FILES ${SOURCES})

# Require at least a C++11 compatible compiler for consumer projects.
target_compile_features(OpenColorIO
PUBLIC cxx_std_11
Expand Down
4 changes: 4 additions & 0 deletions src/apps/ocioarchive/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ ocio_strip_binary(ocioarchive)
install(TARGETS ocioarchive
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ocioarchive)
4 changes: 4 additions & 0 deletions src/apps/ociobakelut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -39,3 +39,7 @@ ocio_strip_binary(ociobakelut)
install(TARGETS ociobakelut
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociobakelut)
4 changes: 4 additions & 0 deletions src/apps/ociocheck/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -28,3 +28,7 @@ ocio_strip_binary(ociocheck)
install(TARGETS ociocheck
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociocheck)
4 changes: 4 additions & 0 deletions src/apps/ociochecklut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,7 @@ ocio_strip_binary(ociochecklut)
install(TARGETS ociochecklut
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociochecklut NEEDS_GL)
4 changes: 4 additions & 0 deletions src/apps/ocioconvert/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,7 @@ ocio_strip_binary(ocioconvert)
install(TARGETS ocioconvert
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ocioconvert NEEDS_GL)
4 changes: 4 additions & 0 deletions src/apps/ociodisplay/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -53,3 +53,7 @@ ocio_strip_binary(ociodisplay)
install(TARGETS ociodisplay
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociodisplay NEEDS_GL)
4 changes: 4 additions & 0 deletions src/apps/ociolutimage/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,7 @@ ocio_strip_binary(ociolutimage)
install(TARGETS ociolutimage
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociolutimage)
4 changes: 4 additions & 0 deletions src/apps/ociomakeclf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,7 @@ ocio_strip_binary(ociomakeclf)
install(TARGETS ociomakeclf
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociomakeclf)
4 changes: 4 additions & 0 deletions src/apps/ociomergeconfigs/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,3 +30,7 @@ ocio_strip_binary(ociomergeconfigs)
install(TARGETS ociomergeconfigs
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociomergeconfigs)
4 changes: 4 additions & 0 deletions src/apps/ocioperf/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,7 @@ ocio_strip_binary(ocioperf)
install(TARGETS ocioperf
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ocioperf)
4 changes: 4 additions & 0 deletions src/apps/ociowrite/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ ocio_strip_binary(ociowrite)
install(TARGETS ociowrite
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
)

# Set the debugger environment so that the executable can be launched
# directly within IDE (e.g. Visual Studio).
set_debugger_env(ociowrite)
36 changes: 21 additions & 15 deletions tests/cpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,28 @@ macro(add_ocio_test_variant NAME BINARY)
endif()
endmacro()

function(add_ocio_test NAME SOURCES PRIVATE_INCLUDES)
function(prepend var prefix)
set(new "")
foreach(f ${ARGN})
list(APPEND new "${prefix}${f}")
endforeach(f)
set(${var} "${new}" PARENT_SCOPE)
endfunction(prepend)

function(add_ocio_test NAME SOURCES TESTS PRIVATE_INCLUDES)
set(TEST_BINARY "test_${NAME}_exec")
set(TEST_NAME "test_${NAME}")
add_executable(${TEST_BINARY} ${SOURCES})

prepend(SOURCES "${PROJECT_SOURCE_DIR}/src/OpenColorIO/" ${SOURCES})
set(SOURCES_ALL ${SOURCES})
list(APPEND SOURCES_ALL ${TESTS})

add_executable(${TEST_BINARY} ${SOURCES_ALL})

# Group the source files to replicate the source tree structure in the IDEs.
source_group(TREE "${PROJECT_SOURCE_DIR}/src/OpenColorIO/" PREFIX "OpenColorIO Library" FILES ${SOURCES})
source_group(TREE "${CMAKE_CURRENT_SOURCE_DIR}" PREFIX "Tests" FILES ${TESTS})

target_compile_definitions(${TEST_BINARY}
PRIVATE
OpenColorIO_SKIP_IMPORTS
Expand Down Expand Up @@ -331,18 +349,6 @@ set(TESTS
ViewTransform_tests.cpp
)

function(prepend var prefix)
set(new "")
foreach(f ${ARGN})
list(APPEND new "${prefix}${f}")
endforeach(f)
set(${var} "${new}" PARENT_SCOPE)
endfunction(prepend)

prepend(SOURCES "${PROJECT_SOURCE_DIR}/src/OpenColorIO/" ${SOURCES})

list(APPEND SOURCES ${TESTS})

if(OCIO_USE_SIMD AND (OCIO_ARCH_X86 OR OCIO_USE_SSE2NEON))
# Note that these files are gated by preprocessors to remove them based on the OCIO_USE_* vars.
set_property(SOURCE "${CMAKE_SOURCE_DIR}/src/OpenColorIO/ops/lut1d/Lut1DOpCPU_SSE2.cpp" APPEND PROPERTY COMPILE_OPTIONS ${OCIO_SSE2_ARGS})
Expand All @@ -359,4 +365,4 @@ if(OCIO_USE_SIMD AND (OCIO_ARCH_X86 OR OCIO_USE_SSE2NEON))
set_property(SOURCE "AVX512_tests.cpp" APPEND PROPERTY COMPILE_OPTIONS ${OCIO_AVX512_ARGS})
endif()

add_ocio_test(cpu "${SOURCES}" TRUE)
add_ocio_test(cpu "${SOURCES}" "${TESTS}" TRUE)
22 changes: 13 additions & 9 deletions tests/gpu/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,20 @@ endif()

# Note: To avoid changing PATH from outside the cmake files.
if(MSVC AND BUILD_SHARED_LIBS)
# Build time list of runtime dll dirs for the exe target.
set(dll_dirs_expr "$<JOIN:$<TARGET_RUNTIME_DLL_DIRS:test_gpu_exec>,;>")

if (MSVC_IDE)
# Note: By default Microsoft Visual Studio editor happens the build type to the build directory.
set(BUILD_TYPE ${CMAKE_BUILD_TYPE})
endif()
# Add folders for glut and glew DLLs.
set(extra_dirs "${GLUT_INCLUDE_DIR}/../bin\\;${GLEW_INCLUDE_DIRS}/../bin\\")

set(NEW_PATH "${PROJECT_BINARY_DIR}/src/OpenColorIO/${BUILD_TYPE}")
set(NEW_PATH "${NEW_PATH}\\\;${GLUT_INCLUDE_DIR}/../bin")
set(NEW_PATH "${NEW_PATH}\\\;${GLEW_INCLUDE_DIRS}/../bin")

set_tests_properties(test_gpu PROPERTIES ENVIRONMENT PATH=${NEW_PATH})
# Tell CTest to use this PATH while launching test_gpu_exec
set_tests_properties(test_gpu PROPERTIES
ENVIRONMENT "PATH=${dll_dirs_expr}\\;${extra_dirs}"
)

# Also set the debugger environment so that you can launch
# test_gpu_exec directly within Visual Studio.
set_property(TARGET test_gpu_exec PROPERTY
VS_DEBUGGER_ENVIRONMENT "PATH=${dll_dirs_expr};${extra_dirs};%PATH%"
)
endif()