├── CMakeLists.txt ├── README.md ├── cmake ├── ArchConfiguration.cmake ├── CMakeCache.txt ├── CMakeFiles │ ├── 3.5.1 │ │ ├── CMakeCCompiler.cmake │ │ ├── CMakeCXXCompiler.cmake │ │ ├── CMakeDetermineCompilerABI_C.bin │ │ ├── CMakeDetermineCompilerABI_CXX.bin │ │ ├── CMakeSystem.cmake │ │ ├── CompilerIdC │ │ │ ├── CMakeCCompilerId.c │ │ │ └── a.out │ │ └── CompilerIdCXX │ │ │ ├── CMakeCXXCompilerId.cpp │ │ │ └── a.out │ ├── cmake.check_cache │ ├── feature_tests.bin │ ├── feature_tests.c │ └── feature_tests.cxx ├── CMakeParseArguments.cmake ├── CommonConfiguration.cmake ├── FindCUDA.cmake ├── FindCUDA │ ├── make2cmake.cmake │ ├── parse_cubin.cmake │ └── run_nvcc.cmake ├── FindDriveworks.cmake ├── FindEGL.cmake ├── FindPackageHandleStandardArgs.cmake ├── FindPackageMessage.cmake ├── LibFindMacros.cmake ├── Samples3rdparty.cmake ├── SamplesConfiguration.cmake ├── SamplesInstallConfiguration.cmake ├── SamplesSetBuildType.cmake └── Toolchain-V4L.cmake ├── launch └── gmsl_n_cameras.launch ├── package.xml └── src ├── Camera.cpp ├── Camera.hpp ├── Checks.hpp ├── ConsoleColor.cpp ├── ConsoleColor.hpp ├── ProgramArguments.cpp ├── ProgramArguments.hpp ├── ResourceManager.cpp ├── ResourceManager.hpp ├── SampleFramework.cpp ├── SampleFramework.hpp ├── Window.hpp ├── WindowEGL.cpp ├── WindowEGL.hpp ├── WindowGLFW.cpp ├── WindowGLFW.hpp ├── cv_connection.cpp ├── cv_connection.hpp └── main.cpp /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.1) 2 | project(gmsl_n_cameras) 3 | 4 | set (CMAKE_CXX_STANDARD 11) 5 | 6 | # FindDriveworks.cmake, ArchConfiguration.cmake, and LibFindMacros.cmake were needed for my setup they are taken from driveworks/samples/cmake/ 7 | # ArchConfiguration.cmake was the only file that needed small changes, remove the fatal error on line 17 and add the following lines in its place 8 | set(VIBRANTE TRUE) 9 | add_definitions(-DVIBRANTE) 10 | # this is the path I placed the driveworks cmake files in 11 | set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_CURRENT_SOURCE_DIR}/cmake") 12 | 13 | find_package(CUDA REQUIRED) 14 | find_package(Threads REQUIRED) 15 | find_package(GLEW REQUIRED) 16 | find_package(Driveworks REQUIRED) 17 | find_package(OpenCV REQUIRED ) 18 | 19 | # SET THESE VARIABLES TO YOUR DRIVEWORKS LOCATIONS 20 | set(Driveworks_INCLUDE_DIR /usr/local/driveworks/include/) 21 | set(Driveworks_LIBRARY /usr/local/driveworks/lib/) 22 | 23 | find_package(catkin REQUIRED COMPONENTS 24 | roscpp 25 | geometry_msgs 26 | cv_bridge 27 | image_transport 28 | ) 29 | 30 | catkin_package( 31 | LIBRARIES ${PROJECT_NAME} 32 | ) 33 | link_directories( 34 | ${Driveworks_LIBRARY}) 35 | 36 | 37 | MESSAGE("Driveworks include directory ${Driveworks_INCLUDE_DIR}") 38 | 39 | include_directories( 40 | ${catkin_INCLUDE_DIRS} 41 | ${Driveworks_INCLUDE_DIR} 42 | ${CUDA_INCLUDE_DIRS} 43 | ${CMAKE_CURRENT_SOURCE_DIR}/src 44 | ${GLEW_INCLUDE_DIR} 45 | ) 46 | 47 | # TODO: add a FindNvmedia.cmake file for this? Why does it not exist? 48 | include_directories(/usr/share/visionworks/sources/3rdparty/nvmedia/ 49 | /usr/share/visionworks/VisionWorks-1.6-Samples/3rdparty/glfw3/include/ 50 | ) 51 | 52 | 53 | # ros node name template 54 | set(NODE_NAME ${PROJECT_NAME}_node) 55 | 56 | add_executable(${NODE_NAME} src/main.cpp 57 | src/ProgramArguments.cpp 58 | src/ConsoleColor.cpp 59 | src/WindowEGL.cpp 60 | src/WindowGLFW.cpp 61 | src/cv_connection.cpp 62 | src/ResourceManager.cpp 63 | src/SampleFramework.cpp 64 | src/Camera.cpp 65 | ) 66 | 67 | target_link_libraries(${NODE_NAME} 68 | ${catkin_LIBRARIES} 69 | nvmedia 70 | ${GLEW_LIBRARY} 71 | driveworks 72 | GLESv2 73 | EGL 74 | drm 75 | #glfw3 76 | ${CUDA_LIBRARY} 77 | ${OpenCV_LIBS} 78 | ) 79 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # gmsl_driver 2 | Require opencv and ROS installed on PX2. 3 | Clone all into your ros catkin_ws/src 4 | After first cmake, need to manually change the directories for driveworks and driveworks lib. I used ccmake to do it. 5 | Require image_transport and cv_bridge in ROS 6 | Add email address to package.xml 7 | 8 | Thanks to Colin Weinshenker for his work on multiple camera driver. 9 | 10 | 11 | Update current status: Our multiple camera driver will dramatically drop frames when record a rosbag. So the solution is we save multiple cameras frames to h264 files and only publish timestamp and frame_id to ROS for post processing. This repo is no longer maintained and will leave it at a base work for anyone working on PX2. 12 | -------------------------------------------------------------------------------- /cmake/ArchConfiguration.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | #------------------------------------------------------------------------------- 4 | # Platform selection 5 | #------------------------------------------------------------------------------- 6 | 7 | if(VIBRANTE) 8 | message(STATUS "Cross Compiling for Vibrante") 9 | elseif(CMAKE_SYSTEM_NAME MATCHES "Windows") 10 | set(WINDOWS TRUE) 11 | add_definitions(-DWINDOWS) 12 | elseif(CMAKE_SYSTEM_NAME MATCHES "Linux") 13 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64") 14 | set(LINUX TRUE) 15 | add_definitions(-DLINUX) 16 | elseif(CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "aarch64") 17 | set(VIBRANTE TRUE) 18 | add_definitions(-DVIBRANTE)) 19 | else() 20 | message(FATAL_ERROR "Unsupported Linux CPU architecture ${CMAKE_SYSTEM_PROCESSOR}.") 21 | endif() 22 | else() 23 | message(FATAL_ERROR "Cannot identify OS") 24 | endif() 25 | 26 | # Position independent code enforce for 64bit systems and armv7l 27 | if(CMAKE_SYSTEM_PROCESSOR STREQUAL "x86_64" OR CMAKE_SYSTEM_PROCESSOR STREQUAL "armv7l") 28 | set(CMAKE_POSITION_INDEPENDENT_CODE ON) 29 | endif() 30 | 31 | #------------------------------------------------------------------------------- 32 | # Architecture selection 33 | #------------------------------------------------------------------------------- 34 | if(MSVC) 35 | # Windows 36 | if(CMAKE_CL_64) 37 | set(ARCH_DIR "Win64") 38 | else() 39 | set(ARCH_DIR "Win32") 40 | message(FATAL_ERROR "Only Win64 builds are supported \ 41 | Please make sure that you build the project with 64 bit compiler.") 42 | endif() 43 | if(MSVC_VERSION EQUAL 1800) 44 | set(ARCH_DIR "${ARCH_DIR}-vc12") 45 | elseif(MSVC_VERSION EQUAL 1900) 46 | set(ARCH_DIR "${ARCH_DIR}-vc14") 47 | endif() 48 | else() 49 | # Linux (either VIBRANTE or PC) 50 | if(VIBRANTE) 51 | # Select device architecture 52 | if(CMAKE_SIZEOF_VOID_P EQUAL 8) 53 | set(ARCH_DIR "linux-aarch64") 54 | else() 55 | set(ARCH_DIR "linux-armv7l") 56 | endif() 57 | else() 58 | set(ARCH_DIR "linux") 59 | endif() 60 | endif() 61 | unset(SDK_ARCH_DIR CACHE) 62 | set(SDK_ARCH_DIR ${ARCH_DIR} CACHE INTERNAL "") 63 | -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CMakeCCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_C_COMPILER "/home/weizhou/Desktop/Host_Machine/vibrante-t186ref-linux/../toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc") 2 | set(CMAKE_C_COMPILER_ARG1 "") 3 | set(CMAKE_C_COMPILER_ID "GNU") 4 | set(CMAKE_C_COMPILER_VERSION "4.9.2") 5 | set(CMAKE_C_COMPILER_WRAPPER "") 6 | set(CMAKE_C_STANDARD_COMPUTED_DEFAULT "90") 7 | set(CMAKE_C_COMPILE_FEATURES "c_function_prototypes;c_restrict;c_variadic_macros;c_static_assert") 8 | set(CMAKE_C90_COMPILE_FEATURES "c_function_prototypes") 9 | set(CMAKE_C99_COMPILE_FEATURES "c_restrict;c_variadic_macros") 10 | set(CMAKE_C11_COMPILE_FEATURES "c_static_assert") 11 | 12 | set(CMAKE_C_PLATFORM_ID "Linux") 13 | set(CMAKE_C_SIMULATE_ID "") 14 | set(CMAKE_C_SIMULATE_VERSION "") 15 | 16 | set(CMAKE_AR "/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-ar") 17 | set(CMAKE_RANLIB "/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-ranlib") 18 | set(CMAKE_LINKER "/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-ld") 19 | set(CMAKE_COMPILER_IS_GNUCC 1) 20 | set(CMAKE_C_COMPILER_LOADED 1) 21 | set(CMAKE_C_COMPILER_WORKS TRUE) 22 | set(CMAKE_C_ABI_COMPILED TRUE) 23 | set(CMAKE_COMPILER_IS_MINGW ) 24 | set(CMAKE_COMPILER_IS_CYGWIN ) 25 | if(CMAKE_COMPILER_IS_CYGWIN) 26 | set(CYGWIN 1) 27 | set(UNIX 1) 28 | endif() 29 | 30 | set(CMAKE_C_COMPILER_ENV_VAR "CC") 31 | 32 | if(CMAKE_COMPILER_IS_MINGW) 33 | set(MINGW 1) 34 | endif() 35 | set(CMAKE_C_COMPILER_ID_RUN 1) 36 | set(CMAKE_C_SOURCE_FILE_EXTENSIONS c;m) 37 | set(CMAKE_C_IGNORE_EXTENSIONS h;H;o;O;obj;OBJ;def;DEF;rc;RC) 38 | set(CMAKE_C_LINKER_PREFERENCE 10) 39 | 40 | # Save compiler ABI information. 41 | set(CMAKE_C_SIZEOF_DATA_PTR "8") 42 | set(CMAKE_C_COMPILER_ABI "ELF") 43 | set(CMAKE_C_LIBRARY_ARCHITECTURE "aarch64-linux-gnu") 44 | 45 | if(CMAKE_C_SIZEOF_DATA_PTR) 46 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_C_SIZEOF_DATA_PTR}") 47 | endif() 48 | 49 | if(CMAKE_C_COMPILER_ABI) 50 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_C_COMPILER_ABI}") 51 | endif() 52 | 53 | if(CMAKE_C_LIBRARY_ARCHITECTURE) 54 | set(CMAKE_LIBRARY_ARCHITECTURE "aarch64-linux-gnu") 55 | endif() 56 | 57 | set(CMAKE_C_CL_SHOWINCLUDES_PREFIX "") 58 | if(CMAKE_C_CL_SHOWINCLUDES_PREFIX) 59 | set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_C_CL_SHOWINCLUDES_PREFIX}") 60 | endif() 61 | 62 | 63 | 64 | 65 | set(CMAKE_C_IMPLICIT_LINK_LIBRARIES "c") 66 | set(CMAKE_C_IMPLICIT_LINK_DIRECTORIES "/lib-target;/targetfs/lib/aarch64-linux-gnu;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/lib/aarch64-gnu-linux/gcc/aarch64-gnu-linux/4.9.2;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/lib/aarch64-gnu-linux/gcc;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/sysroot/lib;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/sysroot/usr/lib/aarch64-gnu-linux/4.9.2;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/sysroot/usr/lib") 67 | set(CMAKE_C_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 68 | -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CMakeCXXCompiler.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_CXX_COMPILER "/home/weizhou/Desktop/Host_Machine/vibrante-t186ref-linux/../toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-g++") 2 | set(CMAKE_CXX_COMPILER_ARG1 "") 3 | set(CMAKE_CXX_COMPILER_ID "GNU") 4 | set(CMAKE_CXX_COMPILER_VERSION "4.9.2") 5 | set(CMAKE_CXX_COMPILER_WRAPPER "") 6 | set(CMAKE_CXX_STANDARD_COMPUTED_DEFAULT "98") 7 | set(CMAKE_CXX_COMPILE_FEATURES "cxx_template_template_parameters;cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates;cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_return_type_deduction") 8 | set(CMAKE_CXX98_COMPILE_FEATURES "cxx_template_template_parameters") 9 | set(CMAKE_CXX11_COMPILE_FEATURES "cxx_alias_templates;cxx_alignas;cxx_alignof;cxx_attributes;cxx_auto_type;cxx_constexpr;cxx_decltype;cxx_decltype_incomplete_return_types;cxx_default_function_template_args;cxx_defaulted_functions;cxx_defaulted_move_initializers;cxx_delegating_constructors;cxx_deleted_functions;cxx_enum_forward_declarations;cxx_explicit_conversions;cxx_extended_friend_declarations;cxx_extern_templates;cxx_final;cxx_func_identifier;cxx_generalized_initializers;cxx_inheriting_constructors;cxx_inline_namespaces;cxx_lambdas;cxx_local_type_template_args;cxx_long_long_type;cxx_noexcept;cxx_nonstatic_member_init;cxx_nullptr;cxx_override;cxx_range_for;cxx_raw_string_literals;cxx_reference_qualified_functions;cxx_right_angle_brackets;cxx_rvalue_references;cxx_sizeof_member;cxx_static_assert;cxx_strong_enums;cxx_thread_local;cxx_trailing_return_types;cxx_unicode_literals;cxx_uniform_initialization;cxx_unrestricted_unions;cxx_user_literals;cxx_variadic_macros;cxx_variadic_templates") 10 | set(CMAKE_CXX14_COMPILE_FEATURES "cxx_attribute_deprecated;cxx_binary_literals;cxx_contextual_conversions;cxx_decltype_auto;cxx_digit_separators;cxx_generic_lambdas;cxx_lambda_init_captures;cxx_return_type_deduction") 11 | 12 | set(CMAKE_CXX_PLATFORM_ID "Linux") 13 | set(CMAKE_CXX_SIMULATE_ID "") 14 | set(CMAKE_CXX_SIMULATE_VERSION "") 15 | 16 | set(CMAKE_AR "/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-ar") 17 | set(CMAKE_RANLIB "/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-ranlib") 18 | set(CMAKE_LINKER "/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-ld") 19 | set(CMAKE_COMPILER_IS_GNUCXX 1) 20 | set(CMAKE_CXX_COMPILER_LOADED 1) 21 | set(CMAKE_CXX_COMPILER_WORKS TRUE) 22 | set(CMAKE_CXX_ABI_COMPILED TRUE) 23 | set(CMAKE_COMPILER_IS_MINGW ) 24 | set(CMAKE_COMPILER_IS_CYGWIN ) 25 | if(CMAKE_COMPILER_IS_CYGWIN) 26 | set(CYGWIN 1) 27 | set(UNIX 1) 28 | endif() 29 | 30 | set(CMAKE_CXX_COMPILER_ENV_VAR "CXX") 31 | 32 | if(CMAKE_COMPILER_IS_MINGW) 33 | set(MINGW 1) 34 | endif() 35 | set(CMAKE_CXX_COMPILER_ID_RUN 1) 36 | set(CMAKE_CXX_IGNORE_EXTENSIONS inl;h;hpp;HPP;H;o;O;obj;OBJ;def;DEF;rc;RC) 37 | set(CMAKE_CXX_SOURCE_FILE_EXTENSIONS C;M;c++;cc;cpp;cxx;mm;CPP) 38 | set(CMAKE_CXX_LINKER_PREFERENCE 30) 39 | set(CMAKE_CXX_LINKER_PREFERENCE_PROPAGATES 1) 40 | 41 | # Save compiler ABI information. 42 | set(CMAKE_CXX_SIZEOF_DATA_PTR "8") 43 | set(CMAKE_CXX_COMPILER_ABI "ELF") 44 | set(CMAKE_CXX_LIBRARY_ARCHITECTURE "aarch64-linux-gnu") 45 | 46 | if(CMAKE_CXX_SIZEOF_DATA_PTR) 47 | set(CMAKE_SIZEOF_VOID_P "${CMAKE_CXX_SIZEOF_DATA_PTR}") 48 | endif() 49 | 50 | if(CMAKE_CXX_COMPILER_ABI) 51 | set(CMAKE_INTERNAL_PLATFORM_ABI "${CMAKE_CXX_COMPILER_ABI}") 52 | endif() 53 | 54 | if(CMAKE_CXX_LIBRARY_ARCHITECTURE) 55 | set(CMAKE_LIBRARY_ARCHITECTURE "aarch64-linux-gnu") 56 | endif() 57 | 58 | set(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX "") 59 | if(CMAKE_CXX_CL_SHOWINCLUDES_PREFIX) 60 | set(CMAKE_CL_SHOWINCLUDES_PREFIX "${CMAKE_CXX_CL_SHOWINCLUDES_PREFIX}") 61 | endif() 62 | 63 | 64 | 65 | 66 | set(CMAKE_CXX_IMPLICIT_LINK_LIBRARIES "stdc++;m;c") 67 | set(CMAKE_CXX_IMPLICIT_LINK_DIRECTORIES "/lib-target;/targetfs/lib/aarch64-linux-gnu;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/lib/aarch64-gnu-linux/gcc/aarch64-gnu-linux/4.9.2;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/lib/aarch64-gnu-linux/gcc;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/sysroot/lib;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/sysroot/usr/lib/aarch64-gnu-linux/4.9.2;/home/weizhou/Desktop/Host_Machine/toolchains/tegra-4.9-nv/usr/sysroot/usr/lib") 68 | set(CMAKE_CXX_IMPLICIT_LINK_FRAMEWORK_DIRECTORIES "") 69 | -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cshort101/gmsl_driver/3afeefb60392eb894f33e5c9db6b9710b3eccc14/cmake/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_C.bin -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cshort101/gmsl_driver/3afeefb60392eb894f33e5c9db6b9710b3eccc14/cmake/CMakeFiles/3.5.1/CMakeDetermineCompilerABI_CXX.bin -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CMakeSystem.cmake: -------------------------------------------------------------------------------- 1 | set(CMAKE_HOST_SYSTEM "Linux-4.4.0-78-generic") 2 | set(CMAKE_HOST_SYSTEM_NAME "Linux") 3 | set(CMAKE_HOST_SYSTEM_VERSION "4.4.0-78-generic") 4 | set(CMAKE_HOST_SYSTEM_PROCESSOR "x86_64") 5 | 6 | include("/usr/local/driveworks-0.2.1/samples-mod/cmake/Toolchain-V4L.cmake") 7 | 8 | set(CMAKE_SYSTEM "Linux-1") 9 | set(CMAKE_SYSTEM_NAME "Linux") 10 | set(CMAKE_SYSTEM_VERSION "1") 11 | set(CMAKE_SYSTEM_PROCESSOR "aarch64") 12 | 13 | set(CMAKE_CROSSCOMPILING "TRUE") 14 | 15 | set(CMAKE_SYSTEM_LOADED 1) 16 | -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CompilerIdC/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cshort101/gmsl_driver/3afeefb60392eb894f33e5c9db6b9710b3eccc14/cmake/CMakeFiles/3.5.1/CompilerIdC/a.out -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CompilerIdCXX/CMakeCXXCompilerId.cpp: -------------------------------------------------------------------------------- 1 | /* This source file must have a .cpp extension so that all C++ compilers 2 | recognize the extension without flags. Borland does not know .cxx for 3 | example. */ 4 | #ifndef __cplusplus 5 | # error "A C compiler has been selected for C++." 6 | #endif 7 | 8 | 9 | /* Version number components: V=Version, R=Revision, P=Patch 10 | Version date components: YYYY=Year, MM=Month, DD=Day */ 11 | 12 | #if defined(__COMO__) 13 | # define COMPILER_ID "Comeau" 14 | /* __COMO_VERSION__ = VRR */ 15 | # define COMPILER_VERSION_MAJOR DEC(__COMO_VERSION__ / 100) 16 | # define COMPILER_VERSION_MINOR DEC(__COMO_VERSION__ % 100) 17 | 18 | #elif defined(__INTEL_COMPILER) || defined(__ICC) 19 | # define COMPILER_ID "Intel" 20 | # if defined(_MSC_VER) 21 | # define SIMULATE_ID "MSVC" 22 | # endif 23 | /* __INTEL_COMPILER = VRP */ 24 | # define COMPILER_VERSION_MAJOR DEC(__INTEL_COMPILER/100) 25 | # define COMPILER_VERSION_MINOR DEC(__INTEL_COMPILER/10 % 10) 26 | # if defined(__INTEL_COMPILER_UPDATE) 27 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER_UPDATE) 28 | # else 29 | # define COMPILER_VERSION_PATCH DEC(__INTEL_COMPILER % 10) 30 | # endif 31 | # if defined(__INTEL_COMPILER_BUILD_DATE) 32 | /* __INTEL_COMPILER_BUILD_DATE = YYYYMMDD */ 33 | # define COMPILER_VERSION_TWEAK DEC(__INTEL_COMPILER_BUILD_DATE) 34 | # endif 35 | # if defined(_MSC_VER) 36 | /* _MSC_VER = VVRR */ 37 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 38 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 39 | # endif 40 | 41 | #elif defined(__PATHCC__) 42 | # define COMPILER_ID "PathScale" 43 | # define COMPILER_VERSION_MAJOR DEC(__PATHCC__) 44 | # define COMPILER_VERSION_MINOR DEC(__PATHCC_MINOR__) 45 | # if defined(__PATHCC_PATCHLEVEL__) 46 | # define COMPILER_VERSION_PATCH DEC(__PATHCC_PATCHLEVEL__) 47 | # endif 48 | 49 | #elif defined(__BORLANDC__) && defined(__CODEGEARC_VERSION__) 50 | # define COMPILER_ID "Embarcadero" 51 | # define COMPILER_VERSION_MAJOR HEX(__CODEGEARC_VERSION__>>24 & 0x00FF) 52 | # define COMPILER_VERSION_MINOR HEX(__CODEGEARC_VERSION__>>16 & 0x00FF) 53 | # define COMPILER_VERSION_PATCH DEC(__CODEGEARC_VERSION__ & 0xFFFF) 54 | 55 | #elif defined(__BORLANDC__) 56 | # define COMPILER_ID "Borland" 57 | /* __BORLANDC__ = 0xVRR */ 58 | # define COMPILER_VERSION_MAJOR HEX(__BORLANDC__>>8) 59 | # define COMPILER_VERSION_MINOR HEX(__BORLANDC__ & 0xFF) 60 | 61 | #elif defined(__WATCOMC__) && __WATCOMC__ < 1200 62 | # define COMPILER_ID "Watcom" 63 | /* __WATCOMC__ = VVRR */ 64 | # define COMPILER_VERSION_MAJOR DEC(__WATCOMC__ / 100) 65 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 66 | # if (__WATCOMC__ % 10) > 0 67 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 68 | # endif 69 | 70 | #elif defined(__WATCOMC__) 71 | # define COMPILER_ID "OpenWatcom" 72 | /* __WATCOMC__ = VVRP + 1100 */ 73 | # define COMPILER_VERSION_MAJOR DEC((__WATCOMC__ - 1100) / 100) 74 | # define COMPILER_VERSION_MINOR DEC((__WATCOMC__ / 10) % 10) 75 | # if (__WATCOMC__ % 10) > 0 76 | # define COMPILER_VERSION_PATCH DEC(__WATCOMC__ % 10) 77 | # endif 78 | 79 | #elif defined(__SUNPRO_CC) 80 | # define COMPILER_ID "SunPro" 81 | # if __SUNPRO_CC >= 0x5100 82 | /* __SUNPRO_CC = 0xVRRP */ 83 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>12) 84 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xFF) 85 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 86 | # else 87 | /* __SUNPRO_CC = 0xVRP */ 88 | # define COMPILER_VERSION_MAJOR HEX(__SUNPRO_CC>>8) 89 | # define COMPILER_VERSION_MINOR HEX(__SUNPRO_CC>>4 & 0xF) 90 | # define COMPILER_VERSION_PATCH HEX(__SUNPRO_CC & 0xF) 91 | # endif 92 | 93 | #elif defined(__HP_aCC) 94 | # define COMPILER_ID "HP" 95 | /* __HP_aCC = VVRRPP */ 96 | # define COMPILER_VERSION_MAJOR DEC(__HP_aCC/10000) 97 | # define COMPILER_VERSION_MINOR DEC(__HP_aCC/100 % 100) 98 | # define COMPILER_VERSION_PATCH DEC(__HP_aCC % 100) 99 | 100 | #elif defined(__DECCXX) 101 | # define COMPILER_ID "Compaq" 102 | /* __DECCXX_VER = VVRRTPPPP */ 103 | # define COMPILER_VERSION_MAJOR DEC(__DECCXX_VER/10000000) 104 | # define COMPILER_VERSION_MINOR DEC(__DECCXX_VER/100000 % 100) 105 | # define COMPILER_VERSION_PATCH DEC(__DECCXX_VER % 10000) 106 | 107 | #elif defined(__IBMCPP__) && defined(__COMPILER_VER__) 108 | # define COMPILER_ID "zOS" 109 | /* __IBMCPP__ = VRP */ 110 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 111 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 112 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 113 | 114 | #elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ >= 800 115 | # define COMPILER_ID "XL" 116 | /* __IBMCPP__ = VRP */ 117 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 118 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 119 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 120 | 121 | #elif defined(__IBMCPP__) && !defined(__COMPILER_VER__) && __IBMCPP__ < 800 122 | # define COMPILER_ID "VisualAge" 123 | /* __IBMCPP__ = VRP */ 124 | # define COMPILER_VERSION_MAJOR DEC(__IBMCPP__/100) 125 | # define COMPILER_VERSION_MINOR DEC(__IBMCPP__/10 % 10) 126 | # define COMPILER_VERSION_PATCH DEC(__IBMCPP__ % 10) 127 | 128 | #elif defined(__PGI) 129 | # define COMPILER_ID "PGI" 130 | # define COMPILER_VERSION_MAJOR DEC(__PGIC__) 131 | # define COMPILER_VERSION_MINOR DEC(__PGIC_MINOR__) 132 | # if defined(__PGIC_PATCHLEVEL__) 133 | # define COMPILER_VERSION_PATCH DEC(__PGIC_PATCHLEVEL__) 134 | # endif 135 | 136 | #elif defined(_CRAYC) 137 | # define COMPILER_ID "Cray" 138 | # define COMPILER_VERSION_MAJOR DEC(_RELEASE_MAJOR) 139 | # define COMPILER_VERSION_MINOR DEC(_RELEASE_MINOR) 140 | 141 | #elif defined(__TI_COMPILER_VERSION__) 142 | # define COMPILER_ID "TI" 143 | /* __TI_COMPILER_VERSION__ = VVVRRRPPP */ 144 | # define COMPILER_VERSION_MAJOR DEC(__TI_COMPILER_VERSION__/1000000) 145 | # define COMPILER_VERSION_MINOR DEC(__TI_COMPILER_VERSION__/1000 % 1000) 146 | # define COMPILER_VERSION_PATCH DEC(__TI_COMPILER_VERSION__ % 1000) 147 | 148 | #elif defined(__FUJITSU) || defined(__FCC_VERSION) || defined(__fcc_version) 149 | # define COMPILER_ID "Fujitsu" 150 | 151 | #elif defined(__SCO_VERSION__) 152 | # define COMPILER_ID "SCO" 153 | 154 | #elif defined(__clang__) && defined(__apple_build_version__) 155 | # define COMPILER_ID "AppleClang" 156 | # if defined(_MSC_VER) 157 | # define SIMULATE_ID "MSVC" 158 | # endif 159 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 160 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 161 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 162 | # if defined(_MSC_VER) 163 | /* _MSC_VER = VVRR */ 164 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 165 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 166 | # endif 167 | # define COMPILER_VERSION_TWEAK DEC(__apple_build_version__) 168 | 169 | #elif defined(__clang__) 170 | # define COMPILER_ID "Clang" 171 | # if defined(_MSC_VER) 172 | # define SIMULATE_ID "MSVC" 173 | # endif 174 | # define COMPILER_VERSION_MAJOR DEC(__clang_major__) 175 | # define COMPILER_VERSION_MINOR DEC(__clang_minor__) 176 | # define COMPILER_VERSION_PATCH DEC(__clang_patchlevel__) 177 | # if defined(_MSC_VER) 178 | /* _MSC_VER = VVRR */ 179 | # define SIMULATE_VERSION_MAJOR DEC(_MSC_VER / 100) 180 | # define SIMULATE_VERSION_MINOR DEC(_MSC_VER % 100) 181 | # endif 182 | 183 | #elif defined(__GNUC__) 184 | # define COMPILER_ID "GNU" 185 | # define COMPILER_VERSION_MAJOR DEC(__GNUC__) 186 | # if defined(__GNUC_MINOR__) 187 | # define COMPILER_VERSION_MINOR DEC(__GNUC_MINOR__) 188 | # endif 189 | # if defined(__GNUC_PATCHLEVEL__) 190 | # define COMPILER_VERSION_PATCH DEC(__GNUC_PATCHLEVEL__) 191 | # endif 192 | 193 | #elif defined(_MSC_VER) 194 | # define COMPILER_ID "MSVC" 195 | /* _MSC_VER = VVRR */ 196 | # define COMPILER_VERSION_MAJOR DEC(_MSC_VER / 100) 197 | # define COMPILER_VERSION_MINOR DEC(_MSC_VER % 100) 198 | # if defined(_MSC_FULL_VER) 199 | # if _MSC_VER >= 1400 200 | /* _MSC_FULL_VER = VVRRPPPPP */ 201 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 100000) 202 | # else 203 | /* _MSC_FULL_VER = VVRRPPPP */ 204 | # define COMPILER_VERSION_PATCH DEC(_MSC_FULL_VER % 10000) 205 | # endif 206 | # endif 207 | # if defined(_MSC_BUILD) 208 | # define COMPILER_VERSION_TWEAK DEC(_MSC_BUILD) 209 | # endif 210 | 211 | #elif defined(__VISUALDSPVERSION__) || defined(__ADSPBLACKFIN__) || defined(__ADSPTS__) || defined(__ADSP21000__) 212 | # define COMPILER_ID "ADSP" 213 | #if defined(__VISUALDSPVERSION__) 214 | /* __VISUALDSPVERSION__ = 0xVVRRPP00 */ 215 | # define COMPILER_VERSION_MAJOR HEX(__VISUALDSPVERSION__>>24) 216 | # define COMPILER_VERSION_MINOR HEX(__VISUALDSPVERSION__>>16 & 0xFF) 217 | # define COMPILER_VERSION_PATCH HEX(__VISUALDSPVERSION__>>8 & 0xFF) 218 | #endif 219 | 220 | #elif defined(__IAR_SYSTEMS_ICC__ ) || defined(__IAR_SYSTEMS_ICC) 221 | # define COMPILER_ID "IAR" 222 | 223 | #elif defined(__ARMCC_VERSION) 224 | # define COMPILER_ID "ARMCC" 225 | #if __ARMCC_VERSION >= 1000000 226 | /* __ARMCC_VERSION = VRRPPPP */ 227 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/1000000) 228 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 100) 229 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 230 | #else 231 | /* __ARMCC_VERSION = VRPPPP */ 232 | # define COMPILER_VERSION_MAJOR DEC(__ARMCC_VERSION/100000) 233 | # define COMPILER_VERSION_MINOR DEC(__ARMCC_VERSION/10000 % 10) 234 | # define COMPILER_VERSION_PATCH DEC(__ARMCC_VERSION % 10000) 235 | #endif 236 | 237 | 238 | #elif defined(_SGI_COMPILER_VERSION) || defined(_COMPILER_VERSION) 239 | # define COMPILER_ID "MIPSpro" 240 | # if defined(_SGI_COMPILER_VERSION) 241 | /* _SGI_COMPILER_VERSION = VRP */ 242 | # define COMPILER_VERSION_MAJOR DEC(_SGI_COMPILER_VERSION/100) 243 | # define COMPILER_VERSION_MINOR DEC(_SGI_COMPILER_VERSION/10 % 10) 244 | # define COMPILER_VERSION_PATCH DEC(_SGI_COMPILER_VERSION % 10) 245 | # else 246 | /* _COMPILER_VERSION = VRP */ 247 | # define COMPILER_VERSION_MAJOR DEC(_COMPILER_VERSION/100) 248 | # define COMPILER_VERSION_MINOR DEC(_COMPILER_VERSION/10 % 10) 249 | # define COMPILER_VERSION_PATCH DEC(_COMPILER_VERSION % 10) 250 | # endif 251 | 252 | 253 | /* These compilers are either not known or too old to define an 254 | identification macro. Try to identify the platform and guess that 255 | it is the native compiler. */ 256 | #elif defined(__sgi) 257 | # define COMPILER_ID "MIPSpro" 258 | 259 | #elif defined(__hpux) || defined(__hpua) 260 | # define COMPILER_ID "HP" 261 | 262 | #else /* unknown compiler */ 263 | # define COMPILER_ID "" 264 | #endif 265 | 266 | /* Construct the string literal in pieces to prevent the source from 267 | getting matched. Store it in a pointer rather than an array 268 | because some compilers will just produce instructions to fill the 269 | array rather than assigning a pointer to a static array. */ 270 | char const* info_compiler = "INFO" ":" "compiler[" COMPILER_ID "]"; 271 | #ifdef SIMULATE_ID 272 | char const* info_simulate = "INFO" ":" "simulate[" SIMULATE_ID "]"; 273 | #endif 274 | 275 | #ifdef __QNXNTO__ 276 | char const* qnxnto = "INFO" ":" "qnxnto[]"; 277 | #endif 278 | 279 | #if defined(__CRAYXE) || defined(__CRAYXC) 280 | char const *info_cray = "INFO" ":" "compiler_wrapper[CrayPrgEnv]"; 281 | #endif 282 | 283 | #define STRINGIFY_HELPER(X) #X 284 | #define STRINGIFY(X) STRINGIFY_HELPER(X) 285 | 286 | /* Identify known platforms by name. */ 287 | #if defined(__linux) || defined(__linux__) || defined(linux) 288 | # define PLATFORM_ID "Linux" 289 | 290 | #elif defined(__CYGWIN__) 291 | # define PLATFORM_ID "Cygwin" 292 | 293 | #elif defined(__MINGW32__) 294 | # define PLATFORM_ID "MinGW" 295 | 296 | #elif defined(__APPLE__) 297 | # define PLATFORM_ID "Darwin" 298 | 299 | #elif defined(_WIN32) || defined(__WIN32__) || defined(WIN32) 300 | # define PLATFORM_ID "Windows" 301 | 302 | #elif defined(__FreeBSD__) || defined(__FreeBSD) 303 | # define PLATFORM_ID "FreeBSD" 304 | 305 | #elif defined(__NetBSD__) || defined(__NetBSD) 306 | # define PLATFORM_ID "NetBSD" 307 | 308 | #elif defined(__OpenBSD__) || defined(__OPENBSD) 309 | # define PLATFORM_ID "OpenBSD" 310 | 311 | #elif defined(__sun) || defined(sun) 312 | # define PLATFORM_ID "SunOS" 313 | 314 | #elif defined(_AIX) || defined(__AIX) || defined(__AIX__) || defined(__aix) || defined(__aix__) 315 | # define PLATFORM_ID "AIX" 316 | 317 | #elif defined(__sgi) || defined(__sgi__) || defined(_SGI) 318 | # define PLATFORM_ID "IRIX" 319 | 320 | #elif defined(__hpux) || defined(__hpux__) 321 | # define PLATFORM_ID "HP-UX" 322 | 323 | #elif defined(__HAIKU__) 324 | # define PLATFORM_ID "Haiku" 325 | 326 | #elif defined(__BeOS) || defined(__BEOS__) || defined(_BEOS) 327 | # define PLATFORM_ID "BeOS" 328 | 329 | #elif defined(__QNX__) || defined(__QNXNTO__) 330 | # define PLATFORM_ID "QNX" 331 | 332 | #elif defined(__tru64) || defined(_tru64) || defined(__TRU64__) 333 | # define PLATFORM_ID "Tru64" 334 | 335 | #elif defined(__riscos) || defined(__riscos__) 336 | # define PLATFORM_ID "RISCos" 337 | 338 | #elif defined(__sinix) || defined(__sinix__) || defined(__SINIX__) 339 | # define PLATFORM_ID "SINIX" 340 | 341 | #elif defined(__UNIX_SV__) 342 | # define PLATFORM_ID "UNIX_SV" 343 | 344 | #elif defined(__bsdos__) 345 | # define PLATFORM_ID "BSDOS" 346 | 347 | #elif defined(_MPRAS) || defined(MPRAS) 348 | # define PLATFORM_ID "MP-RAS" 349 | 350 | #elif defined(__osf) || defined(__osf__) 351 | # define PLATFORM_ID "OSF1" 352 | 353 | #elif defined(_SCO_SV) || defined(SCO_SV) || defined(sco_sv) 354 | # define PLATFORM_ID "SCO_SV" 355 | 356 | #elif defined(__ultrix) || defined(__ultrix__) || defined(_ULTRIX) 357 | # define PLATFORM_ID "ULTRIX" 358 | 359 | #elif defined(__XENIX__) || defined(_XENIX) || defined(XENIX) 360 | # define PLATFORM_ID "Xenix" 361 | 362 | #elif defined(__WATCOMC__) 363 | # if defined(__LINUX__) 364 | # define PLATFORM_ID "Linux" 365 | 366 | # elif defined(__DOS__) 367 | # define PLATFORM_ID "DOS" 368 | 369 | # elif defined(__OS2__) 370 | # define PLATFORM_ID "OS2" 371 | 372 | # elif defined(__WINDOWS__) 373 | # define PLATFORM_ID "Windows3x" 374 | 375 | # else /* unknown platform */ 376 | # define PLATFORM_ID "" 377 | # endif 378 | 379 | #else /* unknown platform */ 380 | # define PLATFORM_ID "" 381 | 382 | #endif 383 | 384 | /* For windows compilers MSVC and Intel we can determine 385 | the architecture of the compiler being used. This is because 386 | the compilers do not have flags that can change the architecture, 387 | but rather depend on which compiler is being used 388 | */ 389 | #if defined(_WIN32) && defined(_MSC_VER) 390 | # if defined(_M_IA64) 391 | # define ARCHITECTURE_ID "IA64" 392 | 393 | # elif defined(_M_X64) || defined(_M_AMD64) 394 | # define ARCHITECTURE_ID "x64" 395 | 396 | # elif defined(_M_IX86) 397 | # define ARCHITECTURE_ID "X86" 398 | 399 | # elif defined(_M_ARM) 400 | # if _M_ARM == 4 401 | # define ARCHITECTURE_ID "ARMV4I" 402 | # elif _M_ARM == 5 403 | # define ARCHITECTURE_ID "ARMV5I" 404 | # else 405 | # define ARCHITECTURE_ID "ARMV" STRINGIFY(_M_ARM) 406 | # endif 407 | 408 | # elif defined(_M_MIPS) 409 | # define ARCHITECTURE_ID "MIPS" 410 | 411 | # elif defined(_M_SH) 412 | # define ARCHITECTURE_ID "SHx" 413 | 414 | # else /* unknown architecture */ 415 | # define ARCHITECTURE_ID "" 416 | # endif 417 | 418 | #elif defined(__WATCOMC__) 419 | # if defined(_M_I86) 420 | # define ARCHITECTURE_ID "I86" 421 | 422 | # elif defined(_M_IX86) 423 | # define ARCHITECTURE_ID "X86" 424 | 425 | # else /* unknown architecture */ 426 | # define ARCHITECTURE_ID "" 427 | # endif 428 | 429 | #else 430 | # define ARCHITECTURE_ID "" 431 | #endif 432 | 433 | /* Convert integer to decimal digit literals. */ 434 | #define DEC(n) \ 435 | ('0' + (((n) / 10000000)%10)), \ 436 | ('0' + (((n) / 1000000)%10)), \ 437 | ('0' + (((n) / 100000)%10)), \ 438 | ('0' + (((n) / 10000)%10)), \ 439 | ('0' + (((n) / 1000)%10)), \ 440 | ('0' + (((n) / 100)%10)), \ 441 | ('0' + (((n) / 10)%10)), \ 442 | ('0' + ((n) % 10)) 443 | 444 | /* Convert integer to hex digit literals. */ 445 | #define HEX(n) \ 446 | ('0' + ((n)>>28 & 0xF)), \ 447 | ('0' + ((n)>>24 & 0xF)), \ 448 | ('0' + ((n)>>20 & 0xF)), \ 449 | ('0' + ((n)>>16 & 0xF)), \ 450 | ('0' + ((n)>>12 & 0xF)), \ 451 | ('0' + ((n)>>8 & 0xF)), \ 452 | ('0' + ((n)>>4 & 0xF)), \ 453 | ('0' + ((n) & 0xF)) 454 | 455 | /* Construct a string literal encoding the version number components. */ 456 | #ifdef COMPILER_VERSION_MAJOR 457 | char const info_version[] = { 458 | 'I', 'N', 'F', 'O', ':', 459 | 'c','o','m','p','i','l','e','r','_','v','e','r','s','i','o','n','[', 460 | COMPILER_VERSION_MAJOR, 461 | # ifdef COMPILER_VERSION_MINOR 462 | '.', COMPILER_VERSION_MINOR, 463 | # ifdef COMPILER_VERSION_PATCH 464 | '.', COMPILER_VERSION_PATCH, 465 | # ifdef COMPILER_VERSION_TWEAK 466 | '.', COMPILER_VERSION_TWEAK, 467 | # endif 468 | # endif 469 | # endif 470 | ']','\0'}; 471 | #endif 472 | 473 | /* Construct a string literal encoding the version number components. */ 474 | #ifdef SIMULATE_VERSION_MAJOR 475 | char const info_simulate_version[] = { 476 | 'I', 'N', 'F', 'O', ':', 477 | 's','i','m','u','l','a','t','e','_','v','e','r','s','i','o','n','[', 478 | SIMULATE_VERSION_MAJOR, 479 | # ifdef SIMULATE_VERSION_MINOR 480 | '.', SIMULATE_VERSION_MINOR, 481 | # ifdef SIMULATE_VERSION_PATCH 482 | '.', SIMULATE_VERSION_PATCH, 483 | # ifdef SIMULATE_VERSION_TWEAK 484 | '.', SIMULATE_VERSION_TWEAK, 485 | # endif 486 | # endif 487 | # endif 488 | ']','\0'}; 489 | #endif 490 | 491 | /* Construct the string literal in pieces to prevent the source from 492 | getting matched. Store it in a pointer rather than an array 493 | because some compilers will just produce instructions to fill the 494 | array rather than assigning a pointer to a static array. */ 495 | char const* info_platform = "INFO" ":" "platform[" PLATFORM_ID "]"; 496 | char const* info_arch = "INFO" ":" "arch[" ARCHITECTURE_ID "]"; 497 | 498 | 499 | 500 | 501 | const char* info_language_dialect_default = "INFO" ":" "dialect_default[" 502 | #if __cplusplus >= 201402L 503 | "14" 504 | #elif __cplusplus >= 201103L 505 | "11" 506 | #else 507 | "98" 508 | #endif 509 | "]"; 510 | 511 | /*--------------------------------------------------------------------------*/ 512 | 513 | int main(int argc, char* argv[]) 514 | { 515 | int require = 0; 516 | require += info_compiler[argc]; 517 | require += info_platform[argc]; 518 | #ifdef COMPILER_VERSION_MAJOR 519 | require += info_version[argc]; 520 | #endif 521 | #ifdef SIMULATE_ID 522 | require += info_simulate[argc]; 523 | #endif 524 | #ifdef SIMULATE_VERSION_MAJOR 525 | require += info_simulate_version[argc]; 526 | #endif 527 | #if defined(__CRAYXE) || defined(__CRAYXC) 528 | require += info_cray[argc]; 529 | #endif 530 | require += info_language_dialect_default[argc]; 531 | (void)argv; 532 | return require; 533 | } 534 | -------------------------------------------------------------------------------- /cmake/CMakeFiles/3.5.1/CompilerIdCXX/a.out: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cshort101/gmsl_driver/3afeefb60392eb894f33e5c9db6b9710b3eccc14/cmake/CMakeFiles/3.5.1/CompilerIdCXX/a.out -------------------------------------------------------------------------------- /cmake/CMakeFiles/cmake.check_cache: -------------------------------------------------------------------------------- 1 | # This file is generated by cmake for dependency checking of the CMakeCache.txt file 2 | -------------------------------------------------------------------------------- /cmake/CMakeFiles/feature_tests.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/cshort101/gmsl_driver/3afeefb60392eb894f33e5c9db6b9710b3eccc14/cmake/CMakeFiles/feature_tests.bin -------------------------------------------------------------------------------- /cmake/CMakeFiles/feature_tests.c: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "C_FEATURE:" 4 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "c_function_prototypes\n" 10 | "C_FEATURE:" 11 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "c_restrict\n" 17 | "C_FEATURE:" 18 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 201000L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "c_static_assert\n" 24 | "C_FEATURE:" 25 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "c_variadic_macros\n" 31 | 32 | }; 33 | 34 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 35 | -------------------------------------------------------------------------------- /cmake/CMakeFiles/feature_tests.cxx: -------------------------------------------------------------------------------- 1 | 2 | const char features[] = {"\n" 3 | "CXX_FEATURE:" 4 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L 5 | "1" 6 | #else 7 | "0" 8 | #endif 9 | "cxx_aggregate_default_initializers\n" 10 | "CXX_FEATURE:" 11 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 12 | "1" 13 | #else 14 | "0" 15 | #endif 16 | "cxx_alias_templates\n" 17 | "CXX_FEATURE:" 18 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 19 | "1" 20 | #else 21 | "0" 22 | #endif 23 | "cxx_alignas\n" 24 | "CXX_FEATURE:" 25 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 26 | "1" 27 | #else 28 | "0" 29 | #endif 30 | "cxx_alignof\n" 31 | "CXX_FEATURE:" 32 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 33 | "1" 34 | #else 35 | "0" 36 | #endif 37 | "cxx_attributes\n" 38 | "CXX_FEATURE:" 39 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 40 | "1" 41 | #else 42 | "0" 43 | #endif 44 | "cxx_attribute_deprecated\n" 45 | "CXX_FEATURE:" 46 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 47 | "1" 48 | #else 49 | "0" 50 | #endif 51 | "cxx_auto_type\n" 52 | "CXX_FEATURE:" 53 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 54 | "1" 55 | #else 56 | "0" 57 | #endif 58 | "cxx_binary_literals\n" 59 | "CXX_FEATURE:" 60 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 61 | "1" 62 | #else 63 | "0" 64 | #endif 65 | "cxx_constexpr\n" 66 | "CXX_FEATURE:" 67 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 68 | "1" 69 | #else 70 | "0" 71 | #endif 72 | "cxx_contextual_conversions\n" 73 | "CXX_FEATURE:" 74 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 75 | "1" 76 | #else 77 | "0" 78 | #endif 79 | "cxx_decltype\n" 80 | "CXX_FEATURE:" 81 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 82 | "1" 83 | #else 84 | "0" 85 | #endif 86 | "cxx_decltype_auto\n" 87 | "CXX_FEATURE:" 88 | #if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L 89 | "1" 90 | #else 91 | "0" 92 | #endif 93 | "cxx_decltype_incomplete_return_types\n" 94 | "CXX_FEATURE:" 95 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 96 | "1" 97 | #else 98 | "0" 99 | #endif 100 | "cxx_default_function_template_args\n" 101 | "CXX_FEATURE:" 102 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 103 | "1" 104 | #else 105 | "0" 106 | #endif 107 | "cxx_defaulted_functions\n" 108 | "CXX_FEATURE:" 109 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 110 | "1" 111 | #else 112 | "0" 113 | #endif 114 | "cxx_defaulted_move_initializers\n" 115 | "CXX_FEATURE:" 116 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 117 | "1" 118 | #else 119 | "0" 120 | #endif 121 | "cxx_delegating_constructors\n" 122 | "CXX_FEATURE:" 123 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 124 | "1" 125 | #else 126 | "0" 127 | #endif 128 | "cxx_deleted_functions\n" 129 | "CXX_FEATURE:" 130 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 131 | "1" 132 | #else 133 | "0" 134 | #endif 135 | "cxx_digit_separators\n" 136 | "CXX_FEATURE:" 137 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 138 | "1" 139 | #else 140 | "0" 141 | #endif 142 | "cxx_enum_forward_declarations\n" 143 | "CXX_FEATURE:" 144 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 145 | "1" 146 | #else 147 | "0" 148 | #endif 149 | "cxx_explicit_conversions\n" 150 | "CXX_FEATURE:" 151 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 152 | "1" 153 | #else 154 | "0" 155 | #endif 156 | "cxx_extended_friend_declarations\n" 157 | "CXX_FEATURE:" 158 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 159 | "1" 160 | #else 161 | "0" 162 | #endif 163 | "cxx_extern_templates\n" 164 | "CXX_FEATURE:" 165 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 166 | "1" 167 | #else 168 | "0" 169 | #endif 170 | "cxx_final\n" 171 | "CXX_FEATURE:" 172 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 173 | "1" 174 | #else 175 | "0" 176 | #endif 177 | "cxx_func_identifier\n" 178 | "CXX_FEATURE:" 179 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 180 | "1" 181 | #else 182 | "0" 183 | #endif 184 | "cxx_generalized_initializers\n" 185 | "CXX_FEATURE:" 186 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 187 | "1" 188 | #else 189 | "0" 190 | #endif 191 | "cxx_generic_lambdas\n" 192 | "CXX_FEATURE:" 193 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 194 | "1" 195 | #else 196 | "0" 197 | #endif 198 | "cxx_inheriting_constructors\n" 199 | "CXX_FEATURE:" 200 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 201 | "1" 202 | #else 203 | "0" 204 | #endif 205 | "cxx_inline_namespaces\n" 206 | "CXX_FEATURE:" 207 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 208 | "1" 209 | #else 210 | "0" 211 | #endif 212 | "cxx_lambdas\n" 213 | "CXX_FEATURE:" 214 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 215 | "1" 216 | #else 217 | "0" 218 | #endif 219 | "cxx_lambda_init_captures\n" 220 | "CXX_FEATURE:" 221 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 222 | "1" 223 | #else 224 | "0" 225 | #endif 226 | "cxx_local_type_template_args\n" 227 | "CXX_FEATURE:" 228 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 229 | "1" 230 | #else 231 | "0" 232 | #endif 233 | "cxx_long_long_type\n" 234 | "CXX_FEATURE:" 235 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 236 | "1" 237 | #else 238 | "0" 239 | #endif 240 | "cxx_noexcept\n" 241 | "CXX_FEATURE:" 242 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 243 | "1" 244 | #else 245 | "0" 246 | #endif 247 | "cxx_nonstatic_member_init\n" 248 | "CXX_FEATURE:" 249 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 250 | "1" 251 | #else 252 | "0" 253 | #endif 254 | "cxx_nullptr\n" 255 | "CXX_FEATURE:" 256 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 257 | "1" 258 | #else 259 | "0" 260 | #endif 261 | "cxx_override\n" 262 | "CXX_FEATURE:" 263 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 264 | "1" 265 | #else 266 | "0" 267 | #endif 268 | "cxx_range_for\n" 269 | "CXX_FEATURE:" 270 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 405 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 271 | "1" 272 | #else 273 | "0" 274 | #endif 275 | "cxx_raw_string_literals\n" 276 | "CXX_FEATURE:" 277 | #if ((__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) >= 40801) && __cplusplus >= 201103L 278 | "1" 279 | #else 280 | "0" 281 | #endif 282 | "cxx_reference_qualified_functions\n" 283 | "CXX_FEATURE:" 284 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L 285 | "1" 286 | #else 287 | "0" 288 | #endif 289 | "cxx_relaxed_constexpr\n" 290 | "CXX_FEATURE:" 291 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 409 && __cplusplus > 201103L 292 | "1" 293 | #else 294 | "0" 295 | #endif 296 | "cxx_return_type_deduction\n" 297 | "CXX_FEATURE:" 298 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 299 | "1" 300 | #else 301 | "0" 302 | #endif 303 | "cxx_right_angle_brackets\n" 304 | "CXX_FEATURE:" 305 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 306 | "1" 307 | #else 308 | "0" 309 | #endif 310 | "cxx_rvalue_references\n" 311 | "CXX_FEATURE:" 312 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 313 | "1" 314 | #else 315 | "0" 316 | #endif 317 | "cxx_sizeof_member\n" 318 | "CXX_FEATURE:" 319 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 320 | "1" 321 | #else 322 | "0" 323 | #endif 324 | "cxx_static_assert\n" 325 | "CXX_FEATURE:" 326 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 327 | "1" 328 | #else 329 | "0" 330 | #endif 331 | "cxx_strong_enums\n" 332 | "CXX_FEATURE:" 333 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && __cplusplus 334 | "1" 335 | #else 336 | "0" 337 | #endif 338 | "cxx_template_template_parameters\n" 339 | "CXX_FEATURE:" 340 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 && __cplusplus >= 201103L 341 | "1" 342 | #else 343 | "0" 344 | #endif 345 | "cxx_thread_local\n" 346 | "CXX_FEATURE:" 347 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 348 | "1" 349 | #else 350 | "0" 351 | #endif 352 | "cxx_trailing_return_types\n" 353 | "CXX_FEATURE:" 354 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 355 | "1" 356 | #else 357 | "0" 358 | #endif 359 | "cxx_unicode_literals\n" 360 | "CXX_FEATURE:" 361 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 362 | "1" 363 | #else 364 | "0" 365 | #endif 366 | "cxx_uniform_initialization\n" 367 | "CXX_FEATURE:" 368 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 406 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 369 | "1" 370 | #else 371 | "0" 372 | #endif 373 | "cxx_unrestricted_unions\n" 374 | "CXX_FEATURE:" 375 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 407 && __cplusplus >= 201103L 376 | "1" 377 | #else 378 | "0" 379 | #endif 380 | "cxx_user_literals\n" 381 | "CXX_FEATURE:" 382 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 500 && __cplusplus >= 201402L 383 | "1" 384 | #else 385 | "0" 386 | #endif 387 | "cxx_variable_templates\n" 388 | "CXX_FEATURE:" 389 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 390 | "1" 391 | #else 392 | "0" 393 | #endif 394 | "cxx_variadic_macros\n" 395 | "CXX_FEATURE:" 396 | #if (__GNUC__ * 100 + __GNUC_MINOR__) >= 404 && (__cplusplus >= 201103L || (defined(__GXX_EXPERIMENTAL_CXX0X__) && __GXX_EXPERIMENTAL_CXX0X__)) 397 | "1" 398 | #else 399 | "0" 400 | #endif 401 | "cxx_variadic_templates\n" 402 | 403 | }; 404 | 405 | int main(int argc, char** argv) { (void)argv; return features[argc]; } 406 | -------------------------------------------------------------------------------- /cmake/CMakeParseArguments.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # CMakeParseArguments 3 | # ------------------- 4 | # 5 | # 6 | # 7 | # CMAKE_PARSE_ARGUMENTS( 8 | # args...) 9 | # 10 | # CMAKE_PARSE_ARGUMENTS() is intended to be used in macros or functions 11 | # for parsing the arguments given to that macro or function. It 12 | # processes the arguments and defines a set of variables which hold the 13 | # values of the respective options. 14 | # 15 | # The argument contains all options for the respective macro, 16 | # i.e. keywords which can be used when calling the macro without any 17 | # value following, like e.g. the OPTIONAL keyword of the install() 18 | # command. 19 | # 20 | # The argument contains all keywords for this macro 21 | # which are followed by one value, like e.g. DESTINATION keyword of the 22 | # install() command. 23 | # 24 | # The argument contains all keywords for this 25 | # macro which can be followed by more than one value, like e.g. the 26 | # TARGETS or FILES keywords of the install() command. 27 | # 28 | # When done, CMAKE_PARSE_ARGUMENTS() will have defined for each of the 29 | # keywords listed in , and 30 | # a variable composed of the given 31 | # followed by "_" and the name of the respective keyword. These 32 | # variables will then hold the respective value from the argument list. 33 | # For the keywords this will be TRUE or FALSE. 34 | # 35 | # All remaining arguments are collected in a variable 36 | # _UNPARSED_ARGUMENTS, this can be checked afterwards to see 37 | # whether your macro was called with unrecognized parameters. 38 | # 39 | # As an example here a my_install() macro, which takes similar arguments 40 | # as the real install() command: 41 | # 42 | # :: 43 | # 44 | # function(MY_INSTALL) 45 | # set(options OPTIONAL FAST) 46 | # set(oneValueArgs DESTINATION RENAME) 47 | # set(multiValueArgs TARGETS CONFIGURATIONS) 48 | # cmake_parse_arguments(MY_INSTALL "${options}" "${oneValueArgs}" 49 | # "${multiValueArgs}" ${ARGN} ) 50 | # ... 51 | # 52 | # 53 | # 54 | # Assume my_install() has been called like this: 55 | # 56 | # :: 57 | # 58 | # my_install(TARGETS foo bar DESTINATION bin OPTIONAL blub) 59 | # 60 | # 61 | # 62 | # After the cmake_parse_arguments() call the macro will have set the 63 | # following variables: 64 | # 65 | # :: 66 | # 67 | # MY_INSTALL_OPTIONAL = TRUE 68 | # MY_INSTALL_FAST = FALSE (this option was not used when calling my_install() 69 | # MY_INSTALL_DESTINATION = "bin" 70 | # MY_INSTALL_RENAME = "" (was not used) 71 | # MY_INSTALL_TARGETS = "foo;bar" 72 | # MY_INSTALL_CONFIGURATIONS = "" (was not used) 73 | # MY_INSTALL_UNPARSED_ARGUMENTS = "blub" (no value expected after "OPTIONAL" 74 | # 75 | # 76 | # 77 | # You can then continue and process these variables. 78 | # 79 | # Keywords terminate lists of values, e.g. if directly after a 80 | # one_value_keyword another recognized keyword follows, this is 81 | # interpreted as the beginning of the new option. E.g. 82 | # my_install(TARGETS foo DESTINATION OPTIONAL) would result in 83 | # MY_INSTALL_DESTINATION set to "OPTIONAL", but MY_INSTALL_DESTINATION 84 | # would be empty and MY_INSTALL_OPTIONAL would be set to TRUE therefor. 85 | 86 | #============================================================================= 87 | # Copyright 2010 Alexander Neundorf 88 | # 89 | # Distributed under the OSI-approved BSD License (the "License"); 90 | # see accompanying file Copyright.txt for details. 91 | # 92 | # This software is distributed WITHOUT ANY WARRANTY; without even the 93 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 94 | # See the License for more information. 95 | #============================================================================= 96 | # (To distribute this file outside of CMake, substitute the full 97 | # License text for the above reference.) 98 | 99 | 100 | if(__CMAKE_PARSE_ARGUMENTS_INCLUDED) 101 | return() 102 | endif() 103 | set(__CMAKE_PARSE_ARGUMENTS_INCLUDED TRUE) 104 | 105 | 106 | function(CMAKE_PARSE_ARGUMENTS prefix _optionNames _singleArgNames _multiArgNames) 107 | # first set all result variables to empty/FALSE 108 | foreach(arg_name ${_singleArgNames} ${_multiArgNames}) 109 | set(${prefix}_${arg_name}) 110 | endforeach() 111 | 112 | foreach(option ${_optionNames}) 113 | set(${prefix}_${option} FALSE) 114 | endforeach() 115 | 116 | set(${prefix}_UNPARSED_ARGUMENTS) 117 | 118 | set(insideValues FALSE) 119 | set(currentArgName) 120 | 121 | # now iterate over all arguments and fill the result variables 122 | foreach(currentArg ${ARGN}) 123 | list(FIND _optionNames "${currentArg}" optionIndex) # ... then this marks the end of the arguments belonging to this keyword 124 | list(FIND _singleArgNames "${currentArg}" singleArgIndex) # ... then this marks the end of the arguments belonging to this keyword 125 | list(FIND _multiArgNames "${currentArg}" multiArgIndex) # ... then this marks the end of the arguments belonging to this keyword 126 | 127 | if(${optionIndex} EQUAL -1 AND ${singleArgIndex} EQUAL -1 AND ${multiArgIndex} EQUAL -1) 128 | if(insideValues) 129 | if("${insideValues}" STREQUAL "SINGLE") 130 | set(${prefix}_${currentArgName} ${currentArg}) 131 | set(insideValues FALSE) 132 | elseif("${insideValues}" STREQUAL "MULTI") 133 | list(APPEND ${prefix}_${currentArgName} ${currentArg}) 134 | endif() 135 | else() 136 | list(APPEND ${prefix}_UNPARSED_ARGUMENTS ${currentArg}) 137 | endif() 138 | else() 139 | if(NOT ${optionIndex} EQUAL -1) 140 | set(${prefix}_${currentArg} TRUE) 141 | set(insideValues FALSE) 142 | elseif(NOT ${singleArgIndex} EQUAL -1) 143 | set(currentArgName ${currentArg}) 144 | set(${prefix}_${currentArgName}) 145 | set(insideValues "SINGLE") 146 | elseif(NOT ${multiArgIndex} EQUAL -1) 147 | set(currentArgName ${currentArg}) 148 | set(${prefix}_${currentArgName}) 149 | set(insideValues "MULTI") 150 | endif() 151 | endif() 152 | 153 | endforeach() 154 | 155 | # propagate the result variables to the caller: 156 | foreach(arg_name ${_singleArgNames} ${_multiArgNames} ${_optionNames}) 157 | set(${prefix}_${arg_name} ${${prefix}_${arg_name}} PARENT_SCOPE) 158 | endforeach() 159 | set(${prefix}_UNPARSED_ARGUMENTS ${${prefix}_UNPARSED_ARGUMENTS} PARENT_SCOPE) 160 | 161 | endfunction() 162 | -------------------------------------------------------------------------------- /cmake/CommonConfiguration.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | #------------------------------------------------------------------------------- 4 | # Enable C++11 5 | #------------------------------------------------------------------------------- 6 | if(CMAKE_VERSION VERSION_GREATER 3.1) 7 | set(CMAKE_CXX_STANDARD 11) 8 | else() 9 | if(LINUX OR VIBRANTE) 10 | include(CheckCXXCompilerFlag) 11 | CHECK_CXX_COMPILER_FLAG(-std=c++11 COMPILER_SUPPORTS_CXX11) 12 | CHECK_CXX_COMPILER_FLAG(-std=c++0x COMPILER_SUPPORTS_CXX0X) 13 | if(COMPILER_SUPPORTS_CXX11) 14 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11") 15 | elseif(COMPILER_SUPPORTS_CXX0X) 16 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++0x") 17 | else() 18 | message(ERROR "Compiler ${CMAKE_CXX_COMPILER} has no C++11 support") 19 | endif() 20 | endif() 21 | endif() 22 | 23 | #------------------------------------------------------------------------------- 24 | # Dependencies 25 | #------------------------------------------------------------------------------- 26 | find_package(Threads REQUIRED) 27 | 28 | if(LINUX) 29 | find_package(X11 REQUIRED) 30 | if (NOT X11_Xrandr_FOUND) 31 | message(FATAL_ERROR "Missing X11_Xrandr library") 32 | endif() 33 | if (NOT X11_Xcursor_FOUND) 34 | message(FATAL_ERROR "Missing X11_Xcursor library") 35 | endif() 36 | if (NOT X11_xf86vmode_FOUND) 37 | message(FATAL_ERROR "Missing X11_xf86vmode library") 38 | endif() 39 | if (NOT X11_Xinerama_FOUND) 40 | message(FATAL_ERROR "Missing X11_Xinerama library") 41 | endif() 42 | if (NOT X11_Xi_FOUND) 43 | message(FATAL_ERROR "Missing X11_Xi library") 44 | endif() 45 | endif() 46 | -------------------------------------------------------------------------------- /cmake/FindCUDA/make2cmake.cmake: -------------------------------------------------------------------------------- 1 | # James Bigler, NVIDIA Corp (nvidia.com - jbigler) 2 | # Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html 3 | # 4 | # Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. 5 | # 6 | # Copyright (c) 2007-2009 7 | # Scientific Computing and Imaging Institute, University of Utah 8 | # 9 | # This code is licensed under the MIT License. See the FindCUDA.cmake script 10 | # for the text of the license. 11 | 12 | # The MIT License 13 | # 14 | # License for the specific language governing rights and limitations under 15 | # Permission is hereby granted, free of charge, to any person obtaining a 16 | # copy of this software and associated documentation files (the "Software"), 17 | # to deal in the Software without restriction, including without limitation 18 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 19 | # and/or sell copies of the Software, and to permit persons to whom the 20 | # Software is furnished to do so, subject to the following conditions: 21 | # 22 | # The above copyright notice and this permission notice shall be included 23 | # in all copies or substantial portions of the Software. 24 | # 25 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 26 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 28 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 30 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 31 | # DEALINGS IN THE SOFTWARE. 32 | # 33 | 34 | ####################################################################### 35 | # This converts a file written in makefile syntax into one that can be included 36 | # by CMake. 37 | 38 | file(READ ${input_file} depend_text) 39 | 40 | if (NOT "${depend_text}" STREQUAL "") 41 | 42 | # message("FOUND DEPENDS") 43 | 44 | string(REPLACE "\\ " " " depend_text ${depend_text}) 45 | 46 | # This works for the nvcc -M generated dependency files. 47 | string(REGEX REPLACE "^.* : " "" depend_text ${depend_text}) 48 | string(REGEX REPLACE "[ \\\\]*\n" ";" depend_text ${depend_text}) 49 | 50 | set(dependency_list "") 51 | 52 | foreach(file ${depend_text}) 53 | 54 | string(REGEX REPLACE "^ +" "" file ${file}) 55 | 56 | # OK, now if we had a UNC path, nvcc has a tendency to only output the first '/' 57 | # instead of '//'. Here we will test to see if the file exists, if it doesn't then 58 | # try to prepend another '/' to the path and test again. If it still fails remove the 59 | # path. 60 | 61 | if(NOT EXISTS "${file}") 62 | if (EXISTS "/${file}") 63 | set(file "/${file}") 64 | else() 65 | message(WARNING " Removing non-existent dependency file: ${file}") 66 | set(file "") 67 | endif() 68 | endif() 69 | 70 | if(NOT IS_DIRECTORY "${file}") 71 | # If softlinks start to matter, we should change this to REALPATH. For now we need 72 | # to flatten paths, because nvcc can generate stuff like /bin/../include instead of 73 | # just /include. 74 | get_filename_component(file_absolute "${file}" ABSOLUTE) 75 | list(APPEND dependency_list "${file_absolute}") 76 | endif() 77 | 78 | endforeach() 79 | 80 | else() 81 | # message("FOUND NO DEPENDS") 82 | endif() 83 | 84 | # Remove the duplicate entries and sort them. 85 | list(REMOVE_DUPLICATES dependency_list) 86 | list(SORT dependency_list) 87 | 88 | foreach(file ${dependency_list}) 89 | set(cuda_nvcc_depend "${cuda_nvcc_depend} \"${file}\"\n") 90 | endforeach() 91 | 92 | file(WRITE ${output_file} "# Generated by: make2cmake.cmake\nSET(CUDA_NVCC_DEPEND\n ${cuda_nvcc_depend})\n\n") 93 | -------------------------------------------------------------------------------- /cmake/FindCUDA/parse_cubin.cmake: -------------------------------------------------------------------------------- 1 | # James Bigler, NVIDIA Corp (nvidia.com - jbigler) 2 | # Abe Stephens, SCI Institute -- http://www.sci.utah.edu/~abe/FindCuda.html 3 | # 4 | # Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. 5 | # 6 | # Copyright (c) 2007-2009 7 | # Scientific Computing and Imaging Institute, University of Utah 8 | # 9 | # This code is licensed under the MIT License. See the FindCUDA.cmake script 10 | # for the text of the license. 11 | 12 | # The MIT License 13 | # 14 | # License for the specific language governing rights and limitations under 15 | # Permission is hereby granted, free of charge, to any person obtaining a 16 | # copy of this software and associated documentation files (the "Software"), 17 | # to deal in the Software without restriction, including without limitation 18 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 19 | # and/or sell copies of the Software, and to permit persons to whom the 20 | # Software is furnished to do so, subject to the following conditions: 21 | # 22 | # The above copyright notice and this permission notice shall be included 23 | # in all copies or substantial portions of the Software. 24 | # 25 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 26 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 27 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 28 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 29 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 30 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 31 | # DEALINGS IN THE SOFTWARE. 32 | # 33 | 34 | ####################################################################### 35 | # Parses a .cubin file produced by nvcc and reports statistics about the file. 36 | 37 | 38 | file(READ ${input_file} file_text) 39 | 40 | if (NOT "${file_text}" STREQUAL "") 41 | 42 | string(REPLACE ";" "\\;" file_text ${file_text}) 43 | string(REPLACE "\ncode" ";code" file_text ${file_text}) 44 | 45 | list(LENGTH file_text len) 46 | 47 | foreach(line ${file_text}) 48 | 49 | # Only look at "code { }" blocks. 50 | if(line MATCHES "^code") 51 | 52 | # Break into individual lines. 53 | string(REGEX REPLACE "\n" ";" line ${line}) 54 | 55 | foreach(entry ${line}) 56 | 57 | # Extract kernel names. 58 | if (${entry} MATCHES "[^g]name = ([^ ]+)") 59 | set(entry "${CMAKE_MATCH_1}") 60 | 61 | # Check to see if the kernel name starts with "_" 62 | set(skip FALSE) 63 | # if (${entry} MATCHES "^_") 64 | # Skip the rest of this block. 65 | # message("Skipping ${entry}") 66 | # set(skip TRUE) 67 | # else () 68 | message("Kernel: ${entry}") 69 | # endif () 70 | 71 | endif() 72 | 73 | # Skip the rest of the block if necessary 74 | if(NOT skip) 75 | 76 | # Registers 77 | if (${entry} MATCHES "reg([ ]+)=([ ]+)([^ ]+)") 78 | set(entry "${CMAKE_MATCH_3}") 79 | message("Registers: ${entry}") 80 | endif() 81 | 82 | # Local memory 83 | if (${entry} MATCHES "lmem([ ]+)=([ ]+)([^ ]+)") 84 | set(entry "${CMAKE_MATCH_3}") 85 | message("Local: ${entry}") 86 | endif() 87 | 88 | # Shared memory 89 | if (${entry} MATCHES "smem([ ]+)=([ ]+)([^ ]+)") 90 | set(entry "${CMAKE_MATCH_3}") 91 | message("Shared: ${entry}") 92 | endif() 93 | 94 | if (${entry} MATCHES "^}") 95 | message("") 96 | endif() 97 | 98 | endif() 99 | 100 | 101 | endforeach() 102 | 103 | endif() 104 | 105 | endforeach() 106 | 107 | else() 108 | # message("FOUND NO DEPENDS") 109 | endif() 110 | 111 | 112 | -------------------------------------------------------------------------------- /cmake/FindCUDA/run_nvcc.cmake: -------------------------------------------------------------------------------- 1 | # James Bigler, NVIDIA Corp (nvidia.com - jbigler) 2 | # 3 | # Copyright (c) 2008 - 2009 NVIDIA Corporation. All rights reserved. 4 | # 5 | # This code is licensed under the MIT License. See the FindCUDA.cmake script 6 | # for the text of the license. 7 | 8 | # The MIT License 9 | # 10 | # License for the specific language governing rights and limitations under 11 | # Permission is hereby granted, free of charge, to any person obtaining a 12 | # copy of this software and associated documentation files (the "Software"), 13 | # to deal in the Software without restriction, including without limitation 14 | # the rights to use, copy, modify, merge, publish, distribute, sublicense, 15 | # and/or sell copies of the Software, and to permit persons to whom the 16 | # Software is furnished to do so, subject to the following conditions: 17 | # 18 | # The above copyright notice and this permission notice shall be included 19 | # in all copies or substantial portions of the Software. 20 | # 21 | # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS 22 | # OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 23 | # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 24 | # THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 25 | # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 26 | # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 27 | # DEALINGS IN THE SOFTWARE. 28 | 29 | 30 | ########################################################################## 31 | # This file runs the nvcc commands to produce the desired output file along with 32 | # the dependency file needed by CMake to compute dependencies. In addition the 33 | # file checks the output of each command and if the command fails it deletes the 34 | # output files. 35 | 36 | # Input variables 37 | # 38 | # verbose:BOOL=<> OFF: Be as quiet as possible (default) 39 | # ON : Describe each step 40 | # 41 | # build_configuration:STRING=<> Typically one of Debug, MinSizeRel, Release, or 42 | # RelWithDebInfo, but it should match one of the 43 | # entries in CUDA_HOST_FLAGS. This is the build 44 | # configuration used when compiling the code. If 45 | # blank or unspecified Debug is assumed as this is 46 | # what CMake does. 47 | # 48 | # generated_file:STRING=<> File to generate. This argument must be passed in. 49 | # 50 | # generated_cubin_file:STRING=<> File to generate. This argument must be passed 51 | # in if build_cubin is true. 52 | 53 | if(NOT generated_file) 54 | message(FATAL_ERROR "You must specify generated_file on the command line") 55 | endif() 56 | 57 | # Set these up as variables to make reading the generated file easier 58 | set(CMAKE_COMMAND "@CMAKE_COMMAND@") # path 59 | set(source_file "@source_file@") # path 60 | set(NVCC_generated_dependency_file "@NVCC_generated_dependency_file@") # path 61 | set(cmake_dependency_file "@cmake_dependency_file@") # path 62 | set(CUDA_make2cmake "@CUDA_make2cmake@") # path 63 | set(CUDA_parse_cubin "@CUDA_parse_cubin@") # path 64 | set(build_cubin @build_cubin@) # bool 65 | set(CUDA_HOST_COMPILER "@CUDA_HOST_COMPILER@") # path 66 | # We won't actually use these variables for now, but we need to set this, in 67 | # order to force this file to be run again if it changes. 68 | set(generated_file_path "@generated_file_path@") # path 69 | set(generated_file_internal "@generated_file@") # path 70 | set(generated_cubin_file_internal "@generated_cubin_file@") # path 71 | 72 | set(CUDA_NVCC_EXECUTABLE "@CUDA_NVCC_EXECUTABLE@") # path 73 | set(CUDA_NVCC_FLAGS @CUDA_NVCC_FLAGS@ ;; @CUDA_WRAP_OPTION_NVCC_FLAGS@) # list 74 | @CUDA_NVCC_FLAGS_CONFIG@ 75 | set(nvcc_flags @nvcc_flags@) # list 76 | set(CUDA_NVCC_INCLUDE_ARGS "@CUDA_NVCC_INCLUDE_ARGS@") # list (needs to be in quotes to handle spaces properly). 77 | set(format_flag "@format_flag@") # string 78 | 79 | if(build_cubin AND NOT generated_cubin_file) 80 | message(FATAL_ERROR "You must specify generated_cubin_file on the command line") 81 | endif() 82 | 83 | # This is the list of host compilation flags. It C or CXX should already have 84 | # been chosen by FindCUDA.cmake. 85 | @CUDA_HOST_FLAGS@ 86 | 87 | # Take the compiler flags and package them up to be sent to the compiler via -Xcompiler 88 | set(nvcc_host_compiler_flags "") 89 | # If we weren't given a build_configuration, use Debug. 90 | if(NOT build_configuration) 91 | set(build_configuration Debug) 92 | endif() 93 | string(TOUPPER "${build_configuration}" build_configuration) 94 | #message("CUDA_NVCC_HOST_COMPILER_FLAGS = ${CUDA_NVCC_HOST_COMPILER_FLAGS}") 95 | foreach(flag ${CMAKE_HOST_FLAGS} ${CMAKE_HOST_FLAGS_${build_configuration}}) 96 | # Extra quotes are added around each flag to help nvcc parse out flags with spaces. 97 | set(nvcc_host_compiler_flags "${nvcc_host_compiler_flags},\"${flag}\"") 98 | endforeach() 99 | if (nvcc_host_compiler_flags) 100 | set(nvcc_host_compiler_flags "-Xcompiler" ${nvcc_host_compiler_flags}) 101 | endif() 102 | #message("nvcc_host_compiler_flags = \"${nvcc_host_compiler_flags}\"") 103 | # Add the build specific configuration flags 104 | list(APPEND CUDA_NVCC_FLAGS ${CUDA_NVCC_FLAGS_${build_configuration}}) 105 | 106 | # Any -ccbin existing in CUDA_NVCC_FLAGS gets highest priority 107 | list( FIND CUDA_NVCC_FLAGS "-ccbin" ccbin_found0 ) 108 | list( FIND CUDA_NVCC_FLAGS "--compiler-bindir" ccbin_found1 ) 109 | if( ccbin_found0 LESS 0 AND ccbin_found1 LESS 0 AND CUDA_HOST_COMPILER ) 110 | if (CUDA_HOST_COMPILER STREQUAL "$(VCInstallDir)bin" AND DEFINED CCBIN) 111 | set(CCBIN -ccbin "${CCBIN}") 112 | else() 113 | set(CCBIN -ccbin "${CUDA_HOST_COMPILER}") 114 | endif() 115 | endif() 116 | 117 | # cuda_execute_process - Executes a command with optional command echo and status message. 118 | # 119 | # status - Status message to print if verbose is true 120 | # command - COMMAND argument from the usual execute_process argument structure 121 | # ARGN - Remaining arguments are the command with arguments 122 | # 123 | # CUDA_result - return value from running the command 124 | # 125 | # Make this a macro instead of a function, so that things like RESULT_VARIABLE 126 | # and other return variables are present after executing the process. 127 | macro(cuda_execute_process status command) 128 | set(_command ${command}) 129 | if(NOT "x${_command}" STREQUAL "xCOMMAND") 130 | message(FATAL_ERROR "Malformed call to cuda_execute_process. Missing COMMAND as second argument. (command = ${command})") 131 | endif() 132 | if(verbose) 133 | execute_process(COMMAND "${CMAKE_COMMAND}" -E echo -- ${status}) 134 | # Now we need to build up our command string. We are accounting for quotes 135 | # and spaces, anything else is left up to the user to fix if they want to 136 | # copy and paste a runnable command line. 137 | set(cuda_execute_process_string) 138 | foreach(arg ${ARGN}) 139 | # If there are quotes, excape them, so they come through. 140 | string(REPLACE "\"" "\\\"" arg ${arg}) 141 | # Args with spaces need quotes around them to get them to be parsed as a single argument. 142 | if(arg MATCHES " ") 143 | list(APPEND cuda_execute_process_string "\"${arg}\"") 144 | else() 145 | list(APPEND cuda_execute_process_string ${arg}) 146 | endif() 147 | endforeach() 148 | # Echo the command 149 | execute_process(COMMAND ${CMAKE_COMMAND} -E echo ${cuda_execute_process_string}) 150 | endif() 151 | # Run the command 152 | execute_process(COMMAND ${ARGN} RESULT_VARIABLE CUDA_result ) 153 | endmacro() 154 | 155 | # Delete the target file 156 | cuda_execute_process( 157 | "Removing ${generated_file}" 158 | COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}" 159 | ) 160 | 161 | # For CUDA 2.3 and below, -G -M doesn't work, so remove the -G flag 162 | # for dependency generation and hope for the best. 163 | set(depends_CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS}") 164 | set(CUDA_VERSION @CUDA_VERSION@) 165 | if(CUDA_VERSION VERSION_LESS "3.0") 166 | cmake_policy(PUSH) 167 | # CMake policy 0007 NEW states that empty list elements are not 168 | # ignored. I'm just setting it to avoid the warning that's printed. 169 | cmake_policy(SET CMP0007 NEW) 170 | # Note that this will remove all occurances of -G. 171 | list(REMOVE_ITEM depends_CUDA_NVCC_FLAGS "-G") 172 | cmake_policy(POP) 173 | endif() 174 | 175 | # nvcc doesn't define __CUDACC__ for some reason when generating dependency files. This 176 | # can cause incorrect dependencies when #including files based on this macro which is 177 | # defined in the generating passes of nvcc invokation. We will go ahead and manually 178 | # define this for now until a future version fixes this bug. 179 | set(CUDACC_DEFINE -D__CUDACC__) 180 | 181 | # Generate the dependency file 182 | cuda_execute_process( 183 | "Generating dependency file: ${NVCC_generated_dependency_file}" 184 | COMMAND "${CUDA_NVCC_EXECUTABLE}" 185 | -M 186 | ${CUDACC_DEFINE} 187 | "${source_file}" 188 | -o "${NVCC_generated_dependency_file}" 189 | ${CCBIN} 190 | ${nvcc_flags} 191 | ${nvcc_host_compiler_flags} 192 | ${depends_CUDA_NVCC_FLAGS} 193 | -DNVCC 194 | ${CUDA_NVCC_INCLUDE_ARGS} 195 | ) 196 | 197 | if(CUDA_result) 198 | message(FATAL_ERROR "Error generating ${generated_file}") 199 | endif() 200 | 201 | # Generate the cmake readable dependency file to a temp file. Don't put the 202 | # quotes just around the filenames for the input_file and output_file variables. 203 | # CMake will pass the quotes through and not be able to find the file. 204 | cuda_execute_process( 205 | "Generating temporary cmake readable file: ${cmake_dependency_file}.tmp" 206 | COMMAND "${CMAKE_COMMAND}" 207 | -D "input_file:FILEPATH=${NVCC_generated_dependency_file}" 208 | -D "output_file:FILEPATH=${cmake_dependency_file}.tmp" 209 | -P "${CUDA_make2cmake}" 210 | ) 211 | 212 | if(CUDA_result) 213 | message(FATAL_ERROR "Error generating ${generated_file}") 214 | endif() 215 | 216 | # Copy the file if it is different 217 | cuda_execute_process( 218 | "Copy if different ${cmake_dependency_file}.tmp to ${cmake_dependency_file}" 219 | COMMAND "${CMAKE_COMMAND}" -E copy_if_different "${cmake_dependency_file}.tmp" "${cmake_dependency_file}" 220 | ) 221 | 222 | if(CUDA_result) 223 | message(FATAL_ERROR "Error generating ${generated_file}") 224 | endif() 225 | 226 | # Delete the temporary file 227 | cuda_execute_process( 228 | "Removing ${cmake_dependency_file}.tmp and ${NVCC_generated_dependency_file}" 229 | COMMAND "${CMAKE_COMMAND}" -E remove "${cmake_dependency_file}.tmp" "${NVCC_generated_dependency_file}" 230 | ) 231 | 232 | if(CUDA_result) 233 | message(FATAL_ERROR "Error generating ${generated_file}") 234 | endif() 235 | 236 | # Generate the code 237 | cuda_execute_process( 238 | "Generating ${generated_file}" 239 | COMMAND "${CUDA_NVCC_EXECUTABLE}" 240 | "${source_file}" 241 | ${format_flag} -o "${generated_file}" 242 | ${CCBIN} 243 | ${nvcc_flags} 244 | ${nvcc_host_compiler_flags} 245 | ${CUDA_NVCC_FLAGS} 246 | -DNVCC 247 | ${CUDA_NVCC_INCLUDE_ARGS} 248 | ) 249 | 250 | if(CUDA_result) 251 | # Since nvcc can sometimes leave half done files make sure that we delete the output file. 252 | cuda_execute_process( 253 | "Removing ${generated_file}" 254 | COMMAND "${CMAKE_COMMAND}" -E remove "${generated_file}" 255 | ) 256 | message(FATAL_ERROR "Error generating file ${generated_file}") 257 | else() 258 | if(verbose) 259 | message("Generated ${generated_file} successfully.") 260 | endif() 261 | endif() 262 | 263 | # Cubin resource report commands. 264 | if( build_cubin ) 265 | # Run with -cubin to produce resource usage report. 266 | cuda_execute_process( 267 | "Generating ${generated_cubin_file}" 268 | COMMAND "${CUDA_NVCC_EXECUTABLE}" 269 | "${source_file}" 270 | ${CUDA_NVCC_FLAGS} 271 | ${nvcc_flags} 272 | ${CCBIN} 273 | ${nvcc_host_compiler_flags} 274 | -DNVCC 275 | -cubin 276 | -o "${generated_cubin_file}" 277 | ${CUDA_NVCC_INCLUDE_ARGS} 278 | ) 279 | 280 | # Execute the parser script. 281 | cuda_execute_process( 282 | "Executing the parser script" 283 | COMMAND "${CMAKE_COMMAND}" 284 | -D "input_file:STRING=${generated_cubin_file}" 285 | -P "${CUDA_parse_cubin}" 286 | ) 287 | 288 | endif() 289 | -------------------------------------------------------------------------------- /cmake/FindDriveworks.cmake: -------------------------------------------------------------------------------- 1 | # Copyright(c)2016, NVIDIA CORPORATION.All rights reserved. 2 | 3 | # - Try to find Driveworks 4 | # Once done, this will define 5 | # 6 | # Driveworks_FOUND - system has Driveworks 7 | # Driveworks_INCLUDE_DIRS - the Driveworks include directories 8 | # Driveworks_LIBRARIES - link these to use Driveworks 9 | 10 | #include(LibFindMacros) 11 | #include(ArchConfiguration) 12 | 13 | # Use pkg-config to get hints about paths 14 | #libfind_pkg_check_modules(Driveworks_PKGCONF driveworks) 15 | 16 | # Use provided driveworks location hints 17 | if(DRIVEWORKS) 18 | if(IS_ABSOLUTE ${DRIVEWORKS}) 19 | set(DRIVEWORKS_DIR ${DRIVEWORKS} CACHE STRING "Path to the driveworks library location" FORCE) 20 | else() 21 | if("${CMAKE_HOST_SYSTEM}" MATCHES ".*Windows.*") 22 | set(sep "\\") 23 | else() 24 | set(sep "/") 25 | endif() 26 | get_filename_component(temp "${SDK_BINARY_DIR}${sep}${DRIVEWORKS}" ABSOLUTE) 27 | set(DRIVEWORKS_DIR ${temp} CACHE STRING "Path to the driveworks library location" FORCE) 28 | endif() 29 | message(STATUS "Driveworks location forced to: ${DRIVEWORKS_DIR}") 30 | else() 31 | set(DRIVEWORKS_DIR "" CACHE STRING "Path to the driveworks library location") 32 | endif() 33 | 34 | # Make sure we support cross-compilation out of the default root path 35 | SET(CMAKE_FIND_ROOT_PATH ${CMAKE_FIND_ROOT_PATH} ${DRIVEWORKS_DIR}) 36 | 37 | # Include dir 38 | find_path(Driveworks_INCLUDE_DIR 39 | NAMES dw/core/Version.h 40 | HINTS ${DRIVEWORKS_DIR}/targets/${CMAKE_SYSTEM_PROCESSOR}-linux/include 41 | ${Driveworks_PKGCONF_INCLUDE_DIRS}/../targets/${CMAKE_SYSTEM_PROCESSOR}-linux/include 42 | PATHS ${CMAKE_CURRENT_SOURCE_DIR}/../targets/${CMAKE_SYSTEM_PROCESSOR}-linux/include 43 | ${CMAKE_CURRENT_SOURCE_DIR}/../include 44 | ${DRIVEWORKS_DIR}/include 45 | ) 46 | 47 | # Finally the library itself 48 | find_library(Driveworks_LIBRARY 49 | NAMES driveworks 50 | HINTS ${DRIVEWORKS_DIR}/targets/${CMAKE_SYSTEM_PROCESSOR}-linux/lib 51 | ${Driveworks_PKGCONF_LIBRARY_DIRS}/../targets/${CMAKE_SYSTEM_PROCESSOR}-linux/lib 52 | PATHS ${CMAKE_CURRENT_SOURCE_DIR}/../targets/${CMAKE_SYSTEM_PROCESSOR}-linux/lib 53 | ${CMAKE_CURRENT_SOURCE_DIR}/../lib 54 | ${DRIVEWORKS_DIR}/lib 55 | ) 56 | 57 | if (NOT DRIVEWORKS AND Driveworks_INCLUDE_DIR AND DRIVEWORKS_DIR STREQUAL "") 58 | get_filename_component(DRIVEWORKS_FROM_INCLUDE ${Driveworks_INCLUDE_DIR} DIRECTORY) 59 | message(STATUS "Driveworks found at: ${DRIVEWORKS_FROM_INCLUDE}") 60 | set(DRIVEWORKS_DIR ${DRIVEWORKS_FROM_INCLUDE} CACHE STRING "Path to the driveworks library location" FORCE) 61 | endif() 62 | 63 | # Set the include dir variables and the libraries and let libfind_process do the rest. 64 | # NOTE: Singular variables for this library, plural for libraries this this lib depends on. 65 | set(Driveworks_PROCESS_INCLUDES Driveworks_INCLUDE_DIR) 66 | set(Driveworks_PROCESS_LIBS Driveworks_LIBRARY) 67 | #libfind_process(Driveworks) 68 | -------------------------------------------------------------------------------- /cmake/FindEGL.cmake: -------------------------------------------------------------------------------- 1 | # Copyright(c)2016, NVIDIA CORPORATION.All rights reserved. 2 | 3 | # - Try to find EGL 4 | # Once done this will define 5 | # EGL_FOUND - System has EGL 6 | # EGL_INCLUDE_DIRS - The EGL include directories 7 | # EGL_LIBRARIES - The libraries needed to use EGL 8 | 9 | find_package(PkgConfig) 10 | pkg_check_modules(PC_EGL QUIET egl) 11 | 12 | find_path(EGL_INCLUDE_DIR EGL/egl.h 13 | HINTS ${PC_EGL_INCLUDEDIR} ${PC_EGL_INCLUDE_DIRS} ${VIBRANTE_PDK}/include) 14 | 15 | find_library(EGL_LIBRARY EGL 16 | HINTS ${PC_EGL_LIBDIR} ${PC_EGL_LIBRARY_DIRS} ${VIBRANTE_PDK}/lib-target) 17 | 18 | set(EGL_LIBRARIES ${EGL_LIBRARY}) 19 | set(EGL_INCLUDE_DIRS ${EGL_INCLUDE_DIR}) 20 | 21 | include(FindPackageHandleStandardArgs) 22 | # handle the QUIETLY and REQUIRED arguments and set EGL_FOUND to TRUE 23 | # if all listed variables are TRUE 24 | find_package_handle_standard_args(EGL DEFAULT_MSG 25 | EGL_LIBRARY EGL_INCLUDE_DIR) 26 | 27 | mark_as_advanced(EGL_INCLUDE_DIR EGL_LIBRARY) 28 | -------------------------------------------------------------------------------- /cmake/FindPackageHandleStandardArgs.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # FindPackageHandleStandardArgs 3 | # ----------------------------- 4 | # 5 | # 6 | # 7 | # FIND_PACKAGE_HANDLE_STANDARD_ARGS( ... ) 8 | # 9 | # This function is intended to be used in FindXXX.cmake modules files. 10 | # It handles the REQUIRED, QUIET and version-related arguments to 11 | # find_package(). It also sets the _FOUND variable. The 12 | # package is considered found if all variables ... listed contain 13 | # valid results, e.g. valid filepaths. 14 | # 15 | # There are two modes of this function. The first argument in both 16 | # modes is the name of the Find-module where it is called (in original 17 | # casing). 18 | # 19 | # The first simple mode looks like this: 20 | # 21 | # :: 22 | # 23 | # FIND_PACKAGE_HANDLE_STANDARD_ARGS( 24 | # (DEFAULT_MSG|"Custom failure message") ... ) 25 | # 26 | # If the variables to are all valid, then 27 | # _FOUND will be set to TRUE. If DEFAULT_MSG is given 28 | # as second argument, then the function will generate itself useful 29 | # success and error messages. You can also supply a custom error 30 | # message for the failure case. This is not recommended. 31 | # 32 | # The second mode is more powerful and also supports version checking: 33 | # 34 | # :: 35 | # 36 | # FIND_PACKAGE_HANDLE_STANDARD_ARGS(NAME 37 | # [FOUND_VAR ] 38 | # [REQUIRED_VARS ...] 39 | # [VERSION_VAR ] 40 | # [HANDLE_COMPONENTS] 41 | # [CONFIG_MODE] 42 | # [FAIL_MESSAGE "Custom failure message"] ) 43 | # 44 | # In this mode, the name of the result-variable can be set either to 45 | # either _FOUND or _FOUND using the 46 | # FOUND_VAR option. Other names for the result-variable are not 47 | # allowed. So for a Find-module named FindFooBar.cmake, the two 48 | # possible names are FooBar_FOUND and FOOBAR_FOUND. It is recommended 49 | # to use the original case version. If the FOUND_VAR option is not 50 | # used, the default is _FOUND. 51 | # 52 | # As in the simple mode, if through are all valid, 53 | # _FOUND will be set to TRUE. After REQUIRED_VARS the 54 | # variables which are required for this package are listed. Following 55 | # VERSION_VAR the name of the variable can be specified which holds the 56 | # version of the package which has been found. If this is done, this 57 | # version will be checked against the (potentially) specified required 58 | # version used in the find_package() call. The EXACT keyword is also 59 | # handled. The default messages include information about the required 60 | # version and the version which has been actually found, both if the 61 | # version is ok or not. If the package supports components, use the 62 | # HANDLE_COMPONENTS option to enable handling them. In this case, 63 | # find_package_handle_standard_args() will report which components have 64 | # been found and which are missing, and the _FOUND variable 65 | # will be set to FALSE if any of the required components (i.e. not the 66 | # ones listed after OPTIONAL_COMPONENTS) are missing. Use the option 67 | # CONFIG_MODE if your FindXXX.cmake module is a wrapper for a 68 | # find_package(... NO_MODULE) call. In this case VERSION_VAR will be 69 | # set to _VERSION and the macro will automatically check whether 70 | # the Config module was found. Via FAIL_MESSAGE a custom failure 71 | # message can be specified, if this is not used, the default message 72 | # will be displayed. 73 | # 74 | # Example for mode 1: 75 | # 76 | # :: 77 | # 78 | # find_package_handle_standard_args(LibXml2 DEFAULT_MSG 79 | # LIBXML2_LIBRARY LIBXML2_INCLUDE_DIR) 80 | # 81 | # 82 | # 83 | # LibXml2 is considered to be found, if both LIBXML2_LIBRARY and 84 | # LIBXML2_INCLUDE_DIR are valid. Then also LIBXML2_FOUND is set to 85 | # TRUE. If it is not found and REQUIRED was used, it fails with 86 | # FATAL_ERROR, independent whether QUIET was used or not. If it is 87 | # found, success will be reported, including the content of . On 88 | # repeated Cmake runs, the same message won't be printed again. 89 | # 90 | # Example for mode 2: 91 | # 92 | # :: 93 | # 94 | # find_package_handle_standard_args(LibXslt 95 | # FOUND_VAR LibXslt_FOUND 96 | # REQUIRED_VARS LibXslt_LIBRARIES LibXslt_INCLUDE_DIRS 97 | # VERSION_VAR LibXslt_VERSION_STRING) 98 | # 99 | # In this case, LibXslt is considered to be found if the variable(s) 100 | # listed after REQUIRED_VAR are all valid, i.e. LibXslt_LIBRARIES and 101 | # LibXslt_INCLUDE_DIRS in this case. The result will then be stored in 102 | # LibXslt_FOUND . Also the version of LibXslt will be checked by using 103 | # the version contained in LibXslt_VERSION_STRING. Since no 104 | # FAIL_MESSAGE is given, the default messages will be printed. 105 | # 106 | # Another example for mode 2: 107 | # 108 | # :: 109 | # 110 | # find_package(Automoc4 QUIET NO_MODULE HINTS /opt/automoc4) 111 | # find_package_handle_standard_args(Automoc4 CONFIG_MODE) 112 | # 113 | # In this case, FindAutmoc4.cmake wraps a call to find_package(Automoc4 114 | # NO_MODULE) and adds an additional search directory for automoc4. Here 115 | # the result will be stored in AUTOMOC4_FOUND. The following 116 | # FIND_PACKAGE_HANDLE_STANDARD_ARGS() call produces a proper 117 | # success/error message. 118 | 119 | #============================================================================= 120 | # Copyright 2007-2009 Kitware, Inc. 121 | # 122 | # Distributed under the OSI-approved BSD License (the "License"); 123 | # see accompanying file Copyright.txt for details. 124 | # 125 | # This software is distributed WITHOUT ANY WARRANTY; without even the 126 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 127 | # See the License for more information. 128 | #============================================================================= 129 | # (To distribute this file outside of CMake, substitute the full 130 | # License text for the above reference.) 131 | 132 | include(${CMAKE_CURRENT_LIST_DIR}/FindPackageMessage.cmake) 133 | include(${CMAKE_CURRENT_LIST_DIR}/CMakeParseArguments.cmake) 134 | 135 | # internal helper macro 136 | macro(_FPHSA_FAILURE_MESSAGE _msg) 137 | if (${_NAME}_FIND_REQUIRED) 138 | message(FATAL_ERROR "${_msg}") 139 | else () 140 | if (NOT ${_NAME}_FIND_QUIETLY) 141 | message(STATUS "${_msg}") 142 | endif () 143 | endif () 144 | endmacro() 145 | 146 | 147 | # internal helper macro to generate the failure message when used in CONFIG_MODE: 148 | macro(_FPHSA_HANDLE_FAILURE_CONFIG_MODE) 149 | # _CONFIG is set, but FOUND is false, this means that some other of the REQUIRED_VARS was not found: 150 | if(${_NAME}_CONFIG) 151 | _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: missing: ${MISSING_VARS} (found ${${_NAME}_CONFIG} ${VERSION_MSG})") 152 | else() 153 | # If _CONSIDERED_CONFIGS is set, the config-file has been found, but no suitable version. 154 | # List them all in the error message: 155 | if(${_NAME}_CONSIDERED_CONFIGS) 156 | set(configsText "") 157 | list(LENGTH ${_NAME}_CONSIDERED_CONFIGS configsCount) 158 | math(EXPR configsCount "${configsCount} - 1") 159 | foreach(currentConfigIndex RANGE ${configsCount}) 160 | list(GET ${_NAME}_CONSIDERED_CONFIGS ${currentConfigIndex} filename) 161 | list(GET ${_NAME}_CONSIDERED_VERSIONS ${currentConfigIndex} version) 162 | set(configsText "${configsText} ${filename} (version ${version})\n") 163 | endforeach() 164 | if (${_NAME}_NOT_FOUND_MESSAGE) 165 | set(configsText "${configsText} Reason given by package: ${${_NAME}_NOT_FOUND_MESSAGE}\n") 166 | endif() 167 | _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} ${VERSION_MSG}, checked the following files:\n${configsText}") 168 | 169 | else() 170 | # Simple case: No Config-file was found at all: 171 | _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: found neither ${_NAME}Config.cmake nor ${_NAME_LOWER}-config.cmake ${VERSION_MSG}") 172 | endif() 173 | endif() 174 | endmacro() 175 | 176 | 177 | function(FIND_PACKAGE_HANDLE_STANDARD_ARGS _NAME _FIRST_ARG) 178 | 179 | # set up the arguments for CMAKE_PARSE_ARGUMENTS and check whether we are in 180 | # new extended or in the "old" mode: 181 | set(options CONFIG_MODE HANDLE_COMPONENTS) 182 | set(oneValueArgs FAIL_MESSAGE VERSION_VAR FOUND_VAR) 183 | set(multiValueArgs REQUIRED_VARS) 184 | set(_KEYWORDS_FOR_EXTENDED_MODE ${options} ${oneValueArgs} ${multiValueArgs} ) 185 | list(FIND _KEYWORDS_FOR_EXTENDED_MODE "${_FIRST_ARG}" INDEX) 186 | 187 | if(${INDEX} EQUAL -1) 188 | set(FPHSA_FAIL_MESSAGE ${_FIRST_ARG}) 189 | set(FPHSA_REQUIRED_VARS ${ARGN}) 190 | set(FPHSA_VERSION_VAR) 191 | else() 192 | 193 | CMAKE_PARSE_ARGUMENTS(FPHSA "${options}" "${oneValueArgs}" "${multiValueArgs}" ${_FIRST_ARG} ${ARGN}) 194 | 195 | if(FPHSA_UNPARSED_ARGUMENTS) 196 | message(FATAL_ERROR "Unknown keywords given to FIND_PACKAGE_HANDLE_STANDARD_ARGS(): \"${FPHSA_UNPARSED_ARGUMENTS}\"") 197 | endif() 198 | 199 | if(NOT FPHSA_FAIL_MESSAGE) 200 | set(FPHSA_FAIL_MESSAGE "DEFAULT_MSG") 201 | endif() 202 | endif() 203 | 204 | # now that we collected all arguments, process them 205 | 206 | if("x${FPHSA_FAIL_MESSAGE}" STREQUAL "xDEFAULT_MSG") 207 | set(FPHSA_FAIL_MESSAGE "Could NOT find ${_NAME}") 208 | endif() 209 | 210 | # In config-mode, we rely on the variable _CONFIG, which is set by find_package() 211 | # when it successfully found the config-file, including version checking: 212 | if(FPHSA_CONFIG_MODE) 213 | list(INSERT FPHSA_REQUIRED_VARS 0 ${_NAME}_CONFIG) 214 | list(REMOVE_DUPLICATES FPHSA_REQUIRED_VARS) 215 | set(FPHSA_VERSION_VAR ${_NAME}_VERSION) 216 | endif() 217 | 218 | if(NOT FPHSA_REQUIRED_VARS) 219 | message(FATAL_ERROR "No REQUIRED_VARS specified for FIND_PACKAGE_HANDLE_STANDARD_ARGS()") 220 | endif() 221 | 222 | list(GET FPHSA_REQUIRED_VARS 0 _FIRST_REQUIRED_VAR) 223 | 224 | string(TOUPPER ${_NAME} _NAME_UPPER) 225 | string(TOLOWER ${_NAME} _NAME_LOWER) 226 | 227 | if(FPHSA_FOUND_VAR) 228 | if(FPHSA_FOUND_VAR MATCHES "^${_NAME}_FOUND$" OR FPHSA_FOUND_VAR MATCHES "^${_NAME_UPPER}_FOUND$") 229 | set(_FOUND_VAR ${FPHSA_FOUND_VAR}) 230 | else() 231 | message(FATAL_ERROR "The argument for FOUND_VAR is \"${FPHSA_FOUND_VAR}\", but only \"${_NAME}_FOUND\" and \"${_NAME_UPPER}_FOUND\" are valid names.") 232 | endif() 233 | else() 234 | set(_FOUND_VAR ${_NAME_UPPER}_FOUND) 235 | endif() 236 | 237 | # collect all variables which were not found, so they can be printed, so the 238 | # user knows better what went wrong (#6375) 239 | set(MISSING_VARS "") 240 | set(DETAILS "") 241 | # check if all passed variables are valid 242 | unset(${_FOUND_VAR}) 243 | foreach(_CURRENT_VAR ${FPHSA_REQUIRED_VARS}) 244 | if(NOT ${_CURRENT_VAR}) 245 | set(${_FOUND_VAR} FALSE) 246 | set(MISSING_VARS "${MISSING_VARS} ${_CURRENT_VAR}") 247 | else() 248 | set(DETAILS "${DETAILS}[${${_CURRENT_VAR}}]") 249 | endif() 250 | endforeach() 251 | if(NOT "${${_FOUND_VAR}}" STREQUAL "FALSE") 252 | set(${_FOUND_VAR} TRUE) 253 | endif() 254 | 255 | # component handling 256 | unset(FOUND_COMPONENTS_MSG) 257 | unset(MISSING_COMPONENTS_MSG) 258 | 259 | if(FPHSA_HANDLE_COMPONENTS) 260 | foreach(comp ${${_NAME}_FIND_COMPONENTS}) 261 | if(${_NAME}_${comp}_FOUND) 262 | 263 | if(NOT DEFINED FOUND_COMPONENTS_MSG) 264 | set(FOUND_COMPONENTS_MSG "found components: ") 265 | endif() 266 | set(FOUND_COMPONENTS_MSG "${FOUND_COMPONENTS_MSG} ${comp}") 267 | 268 | else() 269 | 270 | if(NOT DEFINED MISSING_COMPONENTS_MSG) 271 | set(MISSING_COMPONENTS_MSG "missing components: ") 272 | endif() 273 | set(MISSING_COMPONENTS_MSG "${MISSING_COMPONENTS_MSG} ${comp}") 274 | 275 | if(${_NAME}_FIND_REQUIRED_${comp}) 276 | set(${_FOUND_VAR} FALSE) 277 | set(MISSING_VARS "${MISSING_VARS} ${comp}") 278 | endif() 279 | 280 | endif() 281 | endforeach() 282 | set(COMPONENT_MSG "${FOUND_COMPONENTS_MSG} ${MISSING_COMPONENTS_MSG}") 283 | set(DETAILS "${DETAILS}[c${COMPONENT_MSG}]") 284 | endif() 285 | 286 | # version handling: 287 | set(VERSION_MSG "") 288 | set(VERSION_OK TRUE) 289 | set(VERSION ${${FPHSA_VERSION_VAR}}) 290 | 291 | # check with DEFINED here as the requested or found version may be "0" 292 | if (DEFINED ${_NAME}_FIND_VERSION) 293 | if(DEFINED ${FPHSA_VERSION_VAR}) 294 | 295 | if(${_NAME}_FIND_VERSION_EXACT) # exact version required 296 | # count the dots in the version string 297 | string(REGEX REPLACE "[^.]" "" _VERSION_DOTS "${VERSION}") 298 | # add one dot because there is one dot more than there are components 299 | string(LENGTH "${_VERSION_DOTS}." _VERSION_DOTS) 300 | if (_VERSION_DOTS GREATER ${_NAME}_FIND_VERSION_COUNT) 301 | # Because of the C++ implementation of find_package() ${_NAME}_FIND_VERSION_COUNT 302 | # is at most 4 here. Therefore a simple lookup table is used. 303 | if (${_NAME}_FIND_VERSION_COUNT EQUAL 1) 304 | set(_VERSION_REGEX "[^.]*") 305 | elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 2) 306 | set(_VERSION_REGEX "[^.]*\\.[^.]*") 307 | elseif (${_NAME}_FIND_VERSION_COUNT EQUAL 3) 308 | set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*") 309 | else () 310 | set(_VERSION_REGEX "[^.]*\\.[^.]*\\.[^.]*\\.[^.]*") 311 | endif () 312 | string(REGEX REPLACE "^(${_VERSION_REGEX})\\..*" "\\1" _VERSION_HEAD "${VERSION}") 313 | unset(_VERSION_REGEX) 314 | if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL _VERSION_HEAD) 315 | set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") 316 | set(VERSION_OK FALSE) 317 | else () 318 | set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") 319 | endif () 320 | unset(_VERSION_HEAD) 321 | else () 322 | if (NOT ${_NAME}_FIND_VERSION VERSION_EQUAL VERSION) 323 | set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is exact version \"${${_NAME}_FIND_VERSION}\"") 324 | set(VERSION_OK FALSE) 325 | else () 326 | set(VERSION_MSG "(found suitable exact version \"${VERSION}\")") 327 | endif () 328 | endif () 329 | unset(_VERSION_DOTS) 330 | 331 | else() # minimum version specified: 332 | if (${_NAME}_FIND_VERSION VERSION_GREATER VERSION) 333 | set(VERSION_MSG "Found unsuitable version \"${VERSION}\", but required is at least \"${${_NAME}_FIND_VERSION}\"") 334 | set(VERSION_OK FALSE) 335 | else () 336 | set(VERSION_MSG "(found suitable version \"${VERSION}\", minimum required is \"${${_NAME}_FIND_VERSION}\")") 337 | endif () 338 | endif() 339 | 340 | else() 341 | 342 | # if the package was not found, but a version was given, add that to the output: 343 | if(${_NAME}_FIND_VERSION_EXACT) 344 | set(VERSION_MSG "(Required is exact version \"${${_NAME}_FIND_VERSION}\")") 345 | else() 346 | set(VERSION_MSG "(Required is at least version \"${${_NAME}_FIND_VERSION}\")") 347 | endif() 348 | 349 | endif() 350 | else () 351 | if(VERSION) 352 | set(VERSION_MSG "(found version \"${VERSION}\")") 353 | endif() 354 | endif () 355 | 356 | if(VERSION_OK) 357 | set(DETAILS "${DETAILS}[v${VERSION}(${${_NAME}_FIND_VERSION})]") 358 | else() 359 | set(${_FOUND_VAR} FALSE) 360 | endif() 361 | 362 | 363 | # print the result: 364 | if (${_FOUND_VAR}) 365 | FIND_PACKAGE_MESSAGE(${_NAME} "Found ${_NAME}: ${${_FIRST_REQUIRED_VAR}} ${VERSION_MSG} ${COMPONENT_MSG}" "${DETAILS}") 366 | else () 367 | 368 | if(FPHSA_CONFIG_MODE) 369 | _FPHSA_HANDLE_FAILURE_CONFIG_MODE() 370 | else() 371 | if(NOT VERSION_OK) 372 | _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE}: ${VERSION_MSG} (found ${${_FIRST_REQUIRED_VAR}})") 373 | else() 374 | _FPHSA_FAILURE_MESSAGE("${FPHSA_FAIL_MESSAGE} (missing: ${MISSING_VARS}) ${VERSION_MSG}") 375 | endif() 376 | endif() 377 | 378 | endif () 379 | 380 | set(${_FOUND_VAR} ${${_FOUND_VAR}} PARENT_SCOPE) 381 | 382 | endfunction() 383 | -------------------------------------------------------------------------------- /cmake/FindPackageMessage.cmake: -------------------------------------------------------------------------------- 1 | #.rst: 2 | # FindPackageMessage 3 | # ------------------ 4 | # 5 | # 6 | # 7 | # FIND_PACKAGE_MESSAGE( "message for user" "find result details") 8 | # 9 | # This macro is intended to be used in FindXXX.cmake modules files. It 10 | # will print a message once for each unique find result. This is useful 11 | # for telling the user where a package was found. The first argument 12 | # specifies the name (XXX) of the package. The second argument 13 | # specifies the message to display. The third argument lists details 14 | # about the find result so that if they change the message will be 15 | # displayed again. The macro also obeys the QUIET argument to the 16 | # find_package command. 17 | # 18 | # Example: 19 | # 20 | # :: 21 | # 22 | # if(X11_FOUND) 23 | # FIND_PACKAGE_MESSAGE(X11 "Found X11: ${X11_X11_LIB}" 24 | # "[${X11_X11_LIB}][${X11_INCLUDE_DIR}]") 25 | # else() 26 | # ... 27 | # endif() 28 | 29 | #============================================================================= 30 | # Copyright 2008-2009 Kitware, Inc. 31 | # 32 | # Distributed under the OSI-approved BSD License (the "License"); 33 | # see accompanying file Copyright.txt for details. 34 | # 35 | # This software is distributed WITHOUT ANY WARRANTY; without even the 36 | # implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 37 | # See the License for more information. 38 | #============================================================================= 39 | # (To distribute this file outside of CMake, substitute the full 40 | # License text for the above reference.) 41 | 42 | function(FIND_PACKAGE_MESSAGE pkg msg details) 43 | # Avoid printing a message repeatedly for the same find result. 44 | if(NOT ${pkg}_FIND_QUIETLY) 45 | string(REPLACE "\n" "" details "${details}") 46 | set(DETAILS_VAR FIND_PACKAGE_MESSAGE_DETAILS_${pkg}) 47 | if(NOT "${details}" STREQUAL "${${DETAILS_VAR}}") 48 | # The message has not yet been printed. 49 | message(STATUS "${msg}") 50 | 51 | # Save the find details in the cache to avoid printing the same 52 | # message again. 53 | set("${DETAILS_VAR}" "${details}" 54 | CACHE INTERNAL "Details about finding ${pkg}") 55 | endif() 56 | endif() 57 | endfunction() 58 | -------------------------------------------------------------------------------- /cmake/LibFindMacros.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | # Version 2.2 4 | # Public Domain, originally written by Lasse Kärkkäinen 5 | # Maintained at https://github.com/Tronic/cmake-modules 6 | # Please send your improvements as pull requests on Github. 7 | 8 | # Find another package and make it a dependency of the current package. 9 | # This also automatically forwards the "REQUIRED" argument. 10 | # Usage: libfind_package( [extra args to find_package]) 11 | macro (libfind_package PREFIX PKG) 12 | set(${PREFIX}_args ${PKG} ${ARGN}) 13 | if (${PREFIX}_FIND_REQUIRED) 14 | set(${PREFIX}_args ${${PREFIX}_args} REQUIRED) 15 | endif() 16 | find_package(${${PREFIX}_args}) 17 | set(${PREFIX}_DEPENDENCIES ${${PREFIX}_DEPENDENCIES};${PKG}) 18 | unset(${PREFIX}_args) 19 | endmacro() 20 | 21 | # A simple wrapper to make pkg-config searches a bit easier. 22 | # Works the same as CMake's internal pkg_check_modules but is always quiet. 23 | macro (libfind_pkg_check_modules) 24 | find_package(PkgConfig QUIET) 25 | if (PKG_CONFIG_FOUND) 26 | pkg_check_modules(${ARGN} QUIET) 27 | endif() 28 | endmacro() 29 | 30 | # Avoid useless copy&pasta by doing what most simple libraries do anyway: 31 | # pkg-config, find headers, find library. 32 | # Usage: libfind_pkg_detect( FIND_PATH [other args] FIND_LIBRARY [other args]) 33 | # E.g. libfind_pkg_detect(SDL2 sdl2 FIND_PATH SDL.h PATH_SUFFIXES SDL2 FIND_LIBRARY SDL2) 34 | function (libfind_pkg_detect PREFIX) 35 | # Parse arguments 36 | set(argname pkgargs) 37 | foreach (i ${ARGN}) 38 | if ("${i}" STREQUAL "FIND_PATH") 39 | set(argname pathargs) 40 | elseif ("${i}" STREQUAL "FIND_LIBRARY") 41 | set(argname libraryargs) 42 | else() 43 | set(${argname} ${${argname}} ${i}) 44 | endif() 45 | endforeach() 46 | if (NOT pkgargs) 47 | message(FATAL_ERROR "libfind_pkg_detect requires at least a pkg_config package name to be passed.") 48 | endif() 49 | # Find library 50 | libfind_pkg_check_modules(${PREFIX}_PKGCONF ${pkgargs}) 51 | if (pathargs) 52 | find_path(${PREFIX}_INCLUDE_DIR NAMES ${pathargs} HINTS ${${PREFIX}_PKGCONF_INCLUDE_DIRS}) 53 | endif() 54 | if (libraryargs) 55 | find_library(${PREFIX}_LIBRARY NAMES ${libraryargs} HINTS ${${PREFIX}_PKGCONF_LIBRARY_DIRS}) 56 | endif() 57 | endfunction() 58 | 59 | # Extracts a version #define from a version.h file, output stored to _VERSION. 60 | # Usage: libfind_version_header(Foobar foobar/version.h FOOBAR_VERSION_STR) 61 | # Fourth argument "QUIET" may be used for silently testing different define names. 62 | # This function does nothing if the version variable is already defined. 63 | function (libfind_version_header PREFIX VERSION_H DEFINE_NAME) 64 | # Skip processing if we already have a version or if the include dir was not found 65 | if (${PREFIX}_VERSION OR NOT ${PREFIX}_INCLUDE_DIR) 66 | return() 67 | endif() 68 | set(quiet ${${PREFIX}_FIND_QUIETLY}) 69 | # Process optional arguments 70 | foreach(arg ${ARGN}) 71 | if (arg STREQUAL "QUIET") 72 | set(quiet TRUE) 73 | else() 74 | message(AUTHOR_WARNING "Unknown argument ${arg} to libfind_version_header ignored.") 75 | endif() 76 | endforeach() 77 | # Read the header and parse for version number 78 | set(filename "${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") 79 | if (NOT EXISTS ${filename}) 80 | if (NOT quiet) 81 | message(AUTHOR_WARNING "Unable to find ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") 82 | endif() 83 | return() 84 | endif() 85 | file(READ "${filename}" header) 86 | string(REGEX REPLACE ".*#[ \t]*define[ \t]*${DEFINE_NAME}[ \t]*\"([^\n]*)\".*" "\\1" match "${header}") 87 | # No regex match? 88 | if (match STREQUAL header) 89 | if (NOT quiet) 90 | message(AUTHOR_WARNING "Unable to find \#define ${DEFINE_NAME} \"\" from ${${PREFIX}_INCLUDE_DIR}/${VERSION_H}") 91 | endif() 92 | return() 93 | endif() 94 | # Export the version string 95 | set(${PREFIX}_VERSION "${match}" PARENT_SCOPE) 96 | endfunction() 97 | 98 | # Do the final processing once the paths have been detected. 99 | # If include dirs are needed, ${PREFIX}_PROCESS_INCLUDES should be set to contain 100 | # all the variables, each of which contain one include directory. 101 | # Ditto for ${PREFIX}_PROCESS_LIBS and library files. 102 | # Will set ${PREFIX}_FOUND, ${PREFIX}_INCLUDE_DIRS and ${PREFIX}_LIBRARIES. 103 | # Also handles errors in case library detection was required, etc. 104 | function (libfind_process PREFIX) 105 | # Skip processing if already processed during this configuration run 106 | if (${PREFIX}_FOUND) 107 | return() 108 | endif() 109 | 110 | set(found TRUE) # Start with the assumption that the package was found 111 | 112 | # Did we find any files? Did we miss includes? These are for formatting better error messages. 113 | set(some_files FALSE) 114 | set(missing_headers FALSE) 115 | 116 | # Shorthands for some variables that we need often 117 | set(quiet ${${PREFIX}_FIND_QUIETLY}) 118 | set(required ${${PREFIX}_FIND_REQUIRED}) 119 | set(exactver ${${PREFIX}_FIND_VERSION_EXACT}) 120 | set(findver "${${PREFIX}_FIND_VERSION}") 121 | set(version "${${PREFIX}_VERSION}") 122 | 123 | # Lists of config option names (all, includes, libs) 124 | unset(configopts) 125 | set(includeopts ${${PREFIX}_PROCESS_INCLUDES}) 126 | set(libraryopts ${${PREFIX}_PROCESS_LIBS}) 127 | 128 | # Process deps to add to 129 | foreach (i ${PREFIX} ${${PREFIX}_DEPENDENCIES}) 130 | if (DEFINED ${i}_INCLUDE_OPTS OR DEFINED ${i}_LIBRARY_OPTS) 131 | # The package seems to export option lists that we can use, woohoo! 132 | list(APPEND includeopts ${${i}_INCLUDE_OPTS}) 133 | list(APPEND libraryopts ${${i}_LIBRARY_OPTS}) 134 | else() 135 | # If plural forms don't exist or they equal singular forms 136 | if ((NOT DEFINED ${i}_INCLUDE_DIRS AND NOT DEFINED ${i}_LIBRARIES) OR 137 | ({i}_INCLUDE_DIR STREQUAL ${i}_INCLUDE_DIRS AND ${i}_LIBRARY STREQUAL ${i}_LIBRARIES)) 138 | # Singular forms can be used 139 | if (DEFINED ${i}_INCLUDE_DIR) 140 | list(APPEND includeopts ${i}_INCLUDE_DIR) 141 | endif() 142 | if (DEFINED ${i}_LIBRARY) 143 | list(APPEND libraryopts ${i}_LIBRARY) 144 | endif() 145 | else() 146 | # Oh no, we don't know the option names 147 | message(FATAL_ERROR "We couldn't determine config variable names for ${i} includes and libs. Aieeh!") 148 | endif() 149 | endif() 150 | endforeach() 151 | 152 | if (includeopts) 153 | list(REMOVE_DUPLICATES includeopts) 154 | endif() 155 | 156 | if (libraryopts) 157 | list(REMOVE_DUPLICATES libraryopts) 158 | endif() 159 | 160 | string(REGEX REPLACE ".*[ ;]([^ ;]*(_INCLUDE_DIRS|_LIBRARIES))" "\\1" tmp "${includeopts} ${libraryopts}") 161 | if (NOT tmp STREQUAL "${includeopts} ${libraryopts}") 162 | message(AUTHOR_WARNING "Plural form ${tmp} found in config options of ${PREFIX}. This works as before but is now deprecated. Please only use singular forms INCLUDE_DIR and LIBRARY, and update your find scripts for LibFindMacros > 2.0 automatic dependency system (most often you can simply remove the PROCESS variables entirely).") 163 | endif() 164 | 165 | # Include/library names separated by spaces (notice: not CMake lists) 166 | unset(includes) 167 | unset(libs) 168 | 169 | # Process all includes and set found false if any are missing 170 | foreach (i ${includeopts}) 171 | list(APPEND configopts ${i}) 172 | if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") 173 | list(APPEND includes "${${i}}") 174 | else() 175 | set(found FALSE) 176 | set(missing_headers TRUE) 177 | endif() 178 | endforeach() 179 | 180 | # Process all libraries and set found false if any are missing 181 | foreach (i ${libraryopts}) 182 | list(APPEND configopts ${i}) 183 | if (NOT "${${i}}" STREQUAL "${i}-NOTFOUND") 184 | list(APPEND libs "${${i}}") 185 | else() 186 | set (found FALSE) 187 | endif() 188 | endforeach() 189 | 190 | # Version checks 191 | if (found AND findver) 192 | if (NOT version) 193 | message(WARNING "The find module for ${PREFIX} does not provide version information, so we'll just assume that it is OK. Please fix the module or remove package version requirements to get rid of this warning.") 194 | elseif (version VERSION_LESS findver OR (exactver AND NOT version VERSION_EQUAL findver)) 195 | set(found FALSE) 196 | set(version_unsuitable TRUE) 197 | endif() 198 | endif() 199 | 200 | # If all-OK, hide all config options, export variables, print status and exit 201 | if (found) 202 | foreach (i ${configopts}) 203 | mark_as_advanced(${i}) 204 | endforeach() 205 | if (NOT quiet) 206 | message(STATUS "Found ${PREFIX} ${${PREFIX}_VERSION}") 207 | if (LIBFIND_DEBUG) 208 | message(STATUS " ${PREFIX}_DEPENDENCIES=${${PREFIX}_DEPENDENCIES}") 209 | message(STATUS " ${PREFIX}_INCLUDE_OPTS=${includeopts}") 210 | message(STATUS " ${PREFIX}_INCLUDE_DIRS=${includes}") 211 | message(STATUS " ${PREFIX}_LIBRARY_OPTS=${libraryopts}") 212 | message(STATUS " ${PREFIX}_LIBRARIES=${libs}") 213 | endif() 214 | set (${PREFIX}_INCLUDE_OPTS ${includeopts} PARENT_SCOPE) 215 | set (${PREFIX}_LIBRARY_OPTS ${libraryopts} PARENT_SCOPE) 216 | set (${PREFIX}_INCLUDE_DIRS ${includes} PARENT_SCOPE) 217 | set (${PREFIX}_LIBRARIES ${libs} PARENT_SCOPE) 218 | set (${PREFIX}_FOUND TRUE PARENT_SCOPE) 219 | endif() 220 | return() 221 | endif() 222 | 223 | # Format messages for debug info and the type of error 224 | set(vars "Relevant CMake configuration variables:\n") 225 | foreach (i ${configopts}) 226 | mark_as_advanced(CLEAR ${i}) 227 | set(val ${${i}}) 228 | if ("${val}" STREQUAL "${i}-NOTFOUND") 229 | set (val "") 230 | elseif (val AND NOT EXISTS ${val}) 231 | set (val "${val} (does not exist)") 232 | else() 233 | set(some_files TRUE) 234 | endif() 235 | set(vars "${vars} ${i}=${val}\n") 236 | endforeach() 237 | set(vars "${vars}You may use CMake GUI, cmake -D or ccmake to modify the values. Delete CMakeCache.txt to discard all values and force full re-detection if necessary.\n") 238 | if (version_unsuitable) 239 | set(msg "${PREFIX} ${${PREFIX}_VERSION} was found but") 240 | if (exactver) 241 | set(msg "${msg} only version ${findver} is acceptable.") 242 | else() 243 | set(msg "${msg} version ${findver} is the minimum requirement.") 244 | endif() 245 | else() 246 | if (missing_headers) 247 | set(msg "We could not find development headers for ${PREFIX}. Do you have the necessary dev package installed?") 248 | elseif (some_files) 249 | set(msg "We only found some files of ${PREFIX}, not all of them. Perhaps your installation is incomplete or maybe we just didn't look in the right place?") 250 | if(findver) 251 | set(msg "${msg} This could also be caused by incompatible version (if it helps, at least ${PREFIX} ${findver} should work).") 252 | endif() 253 | else() 254 | set(msg "We were unable to find package ${PREFIX}.") 255 | endif() 256 | endif() 257 | 258 | # Fatal error out if REQUIRED 259 | if (required) 260 | set(msg "REQUIRED PACKAGE NOT FOUND\n${msg} This package is REQUIRED and you need to install it or adjust CMake configuration in order to continue building ${CMAKE_PROJECT_NAME}.") 261 | message(FATAL_ERROR "${msg}\n${vars}") 262 | endif() 263 | # Otherwise just print a nasty warning 264 | if (NOT quiet) 265 | message(WARNING "WARNING: MISSING PACKAGE\n${msg} This package is NOT REQUIRED and you may ignore this warning but by doing so you may miss some functionality of ${CMAKE_PROJECT_NAME}. \n${vars}") 266 | endif() 267 | endfunction() 268 | 269 | -------------------------------------------------------------------------------- /cmake/Samples3rdparty.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | #------------------------------------------------------------------------------- 4 | # Dependencies 5 | #------------------------------------------------------------------------------- 6 | set(glfw3_DIR "/usr/local/driveworks-0.2.1/samples-mod/3rdparty/linux/glfw-3.1.1" CACHE PATH '' FORCE) 7 | set(glew_DIR "/usr/local/driveworks-0.2.1/samples-mod/3rdparty/linux/glew-1.13.0" CACHE PATH '' FORCE) 8 | set(lodepng_DIR "/usr/local/driveworks-0.2.1/samples-mod/3rdparty/linux/lodepng-20150912" CACHE PATH '' FORCE) 9 | find_package(glfw3 REQUIRED CONFIG) 10 | find_package(lodepng CONFIG REQUIRED) 11 | 12 | if(WINDOWS OR LINUX) 13 | find_package(glew REQUIRED CONFIG) 14 | endif() 15 | 16 | if(VIBRANTE) 17 | set(vibrante_DIR "/usr/local/driveworks-0.2.1/samples-mod/3rdparty/linux-aarch64/vibrante" CACHE PATH '' FORCE) 18 | find_package(vibrante REQUIRED CONFIG) 19 | find_package(EGL REQUIRED) 20 | add_definitions(-DDW_USE_NVMEDIA) 21 | add_definitions(-DDW_USE_EGL) 22 | set(DW_USE_NVMEDIA ON) 23 | set(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY BOTH) 24 | set(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE BOTH) 25 | endif() 26 | 27 | # Hide settings in default cmake view 28 | mark_as_advanced(glfw3_DIR glew_DIR lodepng_DIR vibrante_DIR) 29 | -------------------------------------------------------------------------------- /cmake/SamplesConfiguration.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | #------------------------------------------------------------------------------- 4 | # CUDA dependency (needs to be after defining all configurations) 5 | #------------------------------------------------------------------------------- 6 | find_package(CUDA REQUIRED) 7 | set(CUDA_HOST_COMPILER ${CMAKE_CXX_COMPILER}) 8 | include_directories(${CUDA_TOOLKIT_INCLUDE}) 9 | 10 | #------------------------------------------------------------------------------- 11 | # Build flags 12 | #------------------------------------------------------------------------------- 13 | if(MSVC) 14 | if(CMAKE_CXX_FLAGS MATCHES "/W[0-4]") 15 | string(REGEX REPLACE "/W[0-4]" "/W4" CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS}") 16 | else() 17 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4") 18 | endif() 19 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /WX") 20 | 21 | if(CMAKE_GENERATOR MATCHES "NMake Makefiles JOM") 22 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /FS") 23 | endif() 24 | 25 | # Microsoft Visual Studio 2013 gives wrong warning about valid C++11 uniform(bracket) initialization C4351 (http://stackoverflow.com/questions/24122006/vs2013-default-initialization-vs-value-initialization) 26 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4351") 27 | 28 | # Parallel compilation 29 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /MP") 30 | 31 | # Ignore warnings on missing .pdb's for debug builds 32 | set(CMAKE_EXE_LINKER_FLAGS_DEBUG "${CMAKE_EXE_LINKER_FLAGS_DEBUG} /ignore:4099") 33 | 34 | set(CMAKE_RUNTIME_OUTPUT_DIRECTORY "${SDK_BINARY_DIR}/runtime") 35 | elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX) 36 | set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Werror -Wunused -Wunused-value -Wunused-parameter") 37 | 38 | if(NOT VIBRANTE) 39 | set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") 40 | set(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -Wl,--no-undefined -Wl,--as-needed") 41 | endif() 42 | endif() 43 | 44 | #------------------------------------------------------------------------------- 45 | # CUDA configuration 46 | #------------------------------------------------------------------------------- 47 | set(CUDA_NVCC_FLAGS "-arch=sm_30;-lineinfo;-std=c++11;") 48 | 49 | #------------------------------------------------------------------------------- 50 | # Configured headers 51 | #------------------------------------------------------------------------------- 52 | include_directories(${SDK_BINARY_DIR}/configured) 53 | -------------------------------------------------------------------------------- /cmake/SamplesInstallConfiguration.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | #------------------------------------------------------------------------------- 4 | # Samples Installation configuration 5 | #------------------------------------------------------------------------------- 6 | set(SDK_SAMPLE_DESTINATION "bin") 7 | set(SDK_LIBRARY_DESTINATION "lib") 8 | set(SDK_ARCHIVE_DESTINATION "lib") 9 | 10 | function(sdk_install_samples SAMPLES) 11 | install(TARGETS ${SAMPLES} 12 | COMPONENT samples 13 | RUNTIME DESTINATION ${SDK_SAMPLE_DESTINATION} 14 | LIBRARY DESTINATION ${SDK_LIBRARY_DESTINATION} 15 | ARCHIVE DESTINATION ${SDK_ARCHIVE_DESTINATION} 16 | ) 17 | endfunction(sdk_install_samples) 18 | 19 | if(CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT) 20 | set(CMAKE_INSTALL_PREFIX "${SDK_BINARY_DIR}/install" CACHE PATH "Default install path" FORCE) 21 | endif() 22 | message(STATUS "Driveworks Samples install dir: ${CMAKE_INSTALL_PREFIX}") 23 | -------------------------------------------------------------------------------- /cmake/SamplesSetBuildType.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | #------------------------------------------------------------------------------- 4 | # This include makes sure that only (Debug|Release) build types are used 5 | # If no build is specified for a single-configuration generator, Release is used 6 | # by default. 7 | #------------------------------------------------------------------------------- 8 | if("${CMAKE_GENERATOR}" MATCHES "Visual Studio") 9 | #Multi-configuration system, set configuration types 10 | set(CMAKE_CONFIGURATION_TYPES "Debug;Release" CACHE STRING "Configurations") 11 | else() 12 | #Single-configuration system, check build type 13 | if(CMAKE_BUILD_TYPE) 14 | if(NOT "${CMAKE_BUILD_TYPE}" MATCHES "^(Debug|Release)$") 15 | message(WARNING "CMAKE_BUILD_TYPE must be one of (Debug|Release). Using Release as default.") 16 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type. Options: Debug,Release" FORCE) 17 | endif() 18 | else() 19 | message(WARNING "CMAKE_BUILD_TYPE not defined. Using Release as default.") 20 | set(CMAKE_BUILD_TYPE "Release" CACHE STRING "Build type. Options: Debug,Release") 21 | endif() 22 | endif() 23 | -------------------------------------------------------------------------------- /cmake/Toolchain-V4L.cmake: -------------------------------------------------------------------------------- 1 | # Copyright (c) 2016, NVIDIA CORPORATION. All rights reserved. 2 | 3 | set(CMAKE_SYSTEM_NAME "Linux") 4 | set(CMAKE_SYSTEM_VERSION 1) 5 | set(VIBRANTE_BUILD ON) #flags for the CMakeList.txt 6 | set(CMAKE_SYSTEM_PROCESSOR aarch64) 7 | 8 | # need that one here, because this is a toolchain file and hence executed before 9 | # default cmake settings are set 10 | set(CMAKE_FIND_LIBRARY_PREFIXES "lib") 11 | set(CMAKE_FIND_LIBRARY_SUFFIXES ".a" ".so") 12 | 13 | # check that Vibrante PDK must be set 14 | if (NOT DEFINED VIBRANTE_PDK) 15 | if (DEFINED ENV{VIBRANTE_PDK}) 16 | message(STATUS "VIBRANTE_PDK = ENV : $ENV{VIBRANTE_PDK}") 17 | set(VIBRANTE_PDK $ENV{VIBRANTE_PDK} CACHE STRING "Path to the vibrante-XXX-linux path for cross-compilation" FORCE) 18 | endif() 19 | else() 20 | message(STATUS "VIBRANTE_PDK = ${VIBRANTE_PDK}") 21 | endif() 22 | 23 | if(DEFINED VIBRANTE_PDK) 24 | if(NOT IS_ABSOLUTE ${VIBRANTE_PDK}) 25 | get_filename_component(VIBRANTE_PDK "${SDK_BINARY_DIR}/${VIBRANTE_PDK}" ABSOLUTE) 26 | endif() 27 | endif() 28 | 29 | set(ARCH "aarch64") 30 | set(VIBRANTE TRUE) 31 | set(VIBRANTE_V4L TRUE) 32 | add_definitions(-DVIBRANTE -DVIBRANTE_V4L) 33 | 34 | set(TOOLCHAIN "${VIBRANTE_PDK}/../toolchains/tegra-4.9-nv") 35 | 36 | set(CMAKE_CXX_COMPILER "${TOOLCHAIN}/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-g++") 37 | set(CMAKE_C_COMPILER "${TOOLCHAIN}/usr/bin/aarch64-gnu-linux/aarch64-gnu-linux-gcc") 38 | set(GCC_COMPILER_VERSION "4.9" CACHE STRING "GCC Compiler version") 39 | 40 | # setup compiler for cross-compilation 41 | set(CMAKE_CXX_FLAGS "-fPIC" CACHE STRING "c++ flags") 42 | set(CMAKE_C_FLAGS "-fPIC" CACHE STRING "c flags") 43 | set(CMAKE_SHARED_LINKER_FLAGS "" CACHE STRING "shared linker flags") 44 | set(CMAKE_MODULE_LINKER_FLAGS "" CACHE STRING "module linker flags") 45 | set(CMAKE_EXE_LINKER_FLAGS "" CACHE STRING "executable linker flags") 46 | 47 | set(LD_PATH ${VIBRANTE_PDK}/lib-target) 48 | set(LD_PATH_EXTRA ${VIBRANTE_PDK}/targetfs/lib/aarch64-linux-gnu) 49 | 50 | 51 | # Please, be carefull looks like "-Wl,-unresolved-symbols=ignore-in-shared-libs" can lead to silent "ld" problems 52 | set(CMAKE_SHARED_LINKER_FLAGS "-L${LD_PATH} -L${LD_PATH_EXTRA} -Wl,-rpath,${LD_PATH} ${CMAKE_SHARED_LINKER_FLAGS}") 53 | set(CMAKE_EXE_LINKER_FLAGS "-L${LD_PATH} -L${LD_PATH_EXTRA} -Wl,-rpath,${LD_PATH} ${CMAKE_EXE_LINKER_FLAGS}") 54 | 55 | # Set cmake root path. If there is no "/usr/local" in CMAKE_FIND_ROOT_PATH then FinCUDA.cmake doesn't work 56 | SET(CMAKE_FIND_ROOT_PATH ${VIBRANTE_PDK} ${VIBRANTE_PDK}/targetfs/usr/local/ ${VIBRANTE_PDK}/targetfs/ /usr/local) 57 | 58 | # search for programs in the build host directories 59 | SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) 60 | 61 | # for libraries and headers in the target directories 62 | SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) 63 | SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) 64 | 65 | # set system default include dir 66 | include_directories(BEFORE SYSTEM ${VIBRANTE_PDK}/include) 67 | 68 | # determine target device and pdk branch 69 | if (NOT DEFINED VIBRANTE_PDK_DEVICE AND VIBRANTE_PDK) 70 | if(${VIBRANTE_PDK} MATCHES "vibrante-(.+)-linux") 71 | set(VIBRANTE_PDK_DEVICE ${CMAKE_MATCH_1} CACHE STRING "Cross-compilation target device") 72 | message(STATUS "VIBRANTE_PDK_DEVICE = ${VIBRANTE_PDK_DEVICE}") 73 | else() 74 | message(FATAL_ERROR "Can't determine target device for PDK: ${VIBRANTE_PDK}") 75 | endif() 76 | endif() 77 | 78 | if (NOT DEFINED VIBRANTE_PDK_BRANCH AND VIBRANTE_PDK) 79 | if(EXISTS "${VIBRANTE_PDK}/lib-target/version-nv-pdk.txt") 80 | set(VIBRANTE_PDK_FILE "${VIBRANTE_PDK}/lib-target/version-nv-pdk.txt") 81 | elseif(EXISTS "${VIBRANTE_PDK}/lib-target/version-nv-sdk.txt") 82 | set(VIBRANTE_PDK_FILE "${VIBRANTE_PDK}/lib-target/version-nv-sdk.txt") 83 | endif() 84 | 85 | if(VIBRANTE_PDK_FILE) 86 | file(READ ${VIBRANTE_PDK_FILE} version-nv-pdk) 87 | if(${version-nv-pdk} MATCHES "^(.+)-[0123456789]+") 88 | set(VIBRANTE_PDK_BRANCH ${CMAKE_MATCH_1} CACHE STRING "Cross-compilation PDK branch name") 89 | message(STATUS "VIBRANTE_PDK_BRANCH = ${VIBRANTE_PDK_BRANCH}") 90 | else() 91 | message(FATAL_ERROR "Can't determine PDK branch for PDK ${VIBRANTE_PDK}") 92 | endif() 93 | else() 94 | message(FATAL_ERROR "Can't open ${VIBRANTE_PDK}/lib-target/version-nv-(pdk/sdk).txt for PDK branch detection") 95 | endif() 96 | endif() 97 | 98 | if (DEFINED VIBRANTE_PDK_BRANCH) 99 | string(REPLACE "." ";" PDK_VERSION_LIST ${VIBRANTE_PDK_BRANCH}) 100 | 101 | # Some PDK's have less than three version numbers. Pad the list so we always 102 | # have at least three numbers, allowing pre-existing logic depending on major, 103 | # minor, patch versioning to work without modifications 104 | list(LENGTH PDK_VERSION_LIST _PDK_VERSION_LIST_LENGTH) 105 | while(_PDK_VERSION_LIST_LENGTH LESS 3) 106 | list(APPEND PDK_VERSION_LIST 0) 107 | math(EXPR _PDK_VERSION_LIST_LENGTH "${_PDK_VERSION_LIST_LENGTH} + 1") 108 | endwhile() 109 | 110 | set(VIBRANTE_PDK_PATCH 0) 111 | set(VIBRANTE_PDK_BUILD 0) 112 | 113 | list(LENGTH PDK_VERSION_LIST PDK_VERSION_LIST_LENGTH) 114 | 115 | list(GET PDK_VERSION_LIST 0 VIBRANTE_PDK_MAJOR) 116 | list(GET PDK_VERSION_LIST 1 VIBRANTE_PDK_MINOR) 117 | if (PDK_VERSION_LIST_LENGTH GREATER 2) 118 | list(GET PDK_VERSION_LIST 2 VIBRANTE_PDK_PATCH) 119 | endif() 120 | 121 | if (PDK_VERSION_LIST_LENGTH GREATER 3) 122 | list(GET PDK_VERSION_LIST 3 VIBRANTE_PDK_BUILD) 123 | endif() 124 | 125 | add_definitions(-DVIBRANTE_PDK_MAJOR=${VIBRANTE_PDK_MAJOR}) 126 | add_definitions(-DVIBRANTE_PDK_MINOR=${VIBRANTE_PDK_MINOR}) 127 | add_definitions(-DVIBRANTE_PDK_PATCH=${VIBRANTE_PDK_PATCH}) 128 | add_definitions(-DVIBRANTE_PDK_BUILD=${VIBRANTE_PDK_BUILD}) 129 | endif() 130 | -------------------------------------------------------------------------------- /launch/gmsl_n_cameras.launch: -------------------------------------------------------------------------------- 1 | 2 | 3 | 11 | 12 | 13 | 14 | 15 | 16 | -------------------------------------------------------------------------------- /package.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | gmsl_n_cameras 4 | 1.0.0 5 | 6 | Wrapper for Nvidia Driveworks 7 | 8 | 9 | catkin 10 | roscpp 11 | libglew-dev 12 | wei 13 | BSD 14 | 15 | 16 | -------------------------------------------------------------------------------- /src/Camera.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2015-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | 32 | #include 33 | 34 | #include 35 | #include 36 | 37 | 38 | 39 | 40 | 41 | /*--------------------------------------------------------------------------*/ 42 | 43 | 44 | Camera::Camera(dwSensorHandle_t &sensor, dwSensorParams salParams, dwSALHandle_t sal, dwContextHandle_t sdk, ProgramArguments arguments, bool record) 45 | { 46 | // Init dwHandles 47 | this->sensor = DW_NULL_HANDLE; 48 | streamer = DW_NULL_HANDLE; 49 | serializer = DW_NULL_HANDLE; 50 | 51 | 52 | // Are we recording the camera? 53 | this->record = false || record; 54 | 55 | //Initialize sensors 56 | dwStatus result = dwSAL_createSensor(&sensor, salParams, sal); 57 | 58 | // Initialize camera and image properties 59 | if (result == DW_SUCCESS) { 60 | 61 | this->sensor = sensor; 62 | 63 | dwImageProperties cameraImageProperties; 64 | dwSensorCamera_getImageProperties(&cameraImageProperties, 65 | DW_CAMERA_PROCESSED_IMAGE, 66 | this->sensor); 67 | 68 | dwCameraProperties cameraProperties; 69 | dwSensorCamera_getSensorProperties(&cameraProperties, this->sensor); 70 | 71 | width = cameraImageProperties.width; 72 | height = cameraImageProperties.height; 73 | imageType = cameraImageProperties.type; 74 | numSiblings = cameraProperties.siblings; 75 | std::cout << "Camera siblings: " << numSiblings << std::endl; 76 | } 77 | else { 78 | std::cerr << "Cannot create driver: " << salParams.protocol 79 | << " with params: " << salParams.parameters << std::endl 80 | << "Error: " << dwGetStatusName(result) << std::endl; 81 | if (result == DW_INVALID_ARGUMENT) { 82 | std::cerr << "It is possible the given camera is not supported. " << std::endl; 83 | } 84 | } 85 | 86 | initImagePool(sdk); 87 | initFormatter(sdk); 88 | if (record) initSerializer(arguments); 89 | } 90 | 91 | /*--------------------------------------------------------------------------*/ 92 | 93 | 94 | /* 95 | 96 | Initialize RGBA Image Pool for each Camera Port 97 | 98 | */ 99 | void Camera::initImagePool(dwContextHandle_t sdk) 100 | { 101 | 102 | NvMediaDevice *nvmedia; 103 | dwContext_getNvMediaDevice(&nvmedia, sdk); 104 | 105 | 106 | for (int i = 0; i < numSiblings; ++i) { 107 | 108 | NvMediaImageAdvancedConfig advConfig; 109 | memset(&advConfig, 0, sizeof(advConfig)); 110 | dwImageNvMedia *rgbaImage = new dwImageNvMedia(); 111 | NvMediaImage *rgbaNvMediaImage; 112 | 113 | 114 | rgbaNvMediaImage = NvMediaImageCreate(nvmedia, NvMediaSurfaceType_Image_RGBA, 115 | NVMEDIA_IMAGE_CLASS_SINGLE_IMAGE, 1, 116 | width, height, 117 | 0, 118 | &advConfig); 119 | dwImageNvMedia_setFromImage(rgbaImage, rgbaNvMediaImage); 120 | 121 | 122 | rgbaImagePool.push_back(rgbaImage); 123 | } 124 | 125 | 126 | std::cout << "Image pool created" << std::endl; 127 | 128 | } 129 | 130 | /*--------------------------------------------------------------------------*/ 131 | 132 | 133 | 134 | /* Initialize the image formatter */ 135 | 136 | void Camera::initFormatter(dwContextHandle_t sdk) { 137 | 138 | dwImageProperties cameraImageProperties; 139 | dwSensorCamera_getImageProperties(&cameraImageProperties, DW_CAMERA_PROCESSED_IMAGE, sensor); 140 | dwImageProperties displayImageProperties = cameraImageProperties; 141 | displayImageProperties.pxlFormat = DW_IMAGE_RGBA; 142 | displayImageProperties.planeCount = 1; 143 | 144 | dwImageFormatConverterHandle_t yuv2rgba = DW_NULL_HANDLE; 145 | dwStatus status = dwImageFormatConverter_initialize(&yuv2rgba, 146 | &cameraImageProperties, 147 | &displayImageProperties, 148 | sdk); 149 | if (status != DW_SUCCESS) { 150 | std::cerr << "Cannot initialize pixel format converter" << std::endl; 151 | exit(1); 152 | } 153 | else { 154 | converter = yuv2rgba; 155 | std::cout << "Pixel format converter created" << std::endl; 156 | } 157 | } 158 | 159 | /*--------------------------------------------------------------------------*/ 160 | 161 | 162 | /* Initialize a data serializer for the camera */ 163 | void Camera::initSerializer(ProgramArguments arguments) { 164 | 165 | dwSerializerParams serializerParams; 166 | serializerParams.parameters = ""; 167 | if (record) { 168 | std::string newParams = ""; 169 | if (arguments.has("serialize-type")) { 170 | newParams += 171 | std::string("format=") + std::string(arguments.get("serialize-type")); 172 | } 173 | if (arguments.has("serialize-bitrate")) { 174 | newParams += 175 | std::string(",bitrate=") + std::string(arguments.get("serialize-bitrate")); 176 | } 177 | if (arguments.has("serialize-framerate")) { 178 | newParams += 179 | std::string(",framerate=") + std::string(arguments.get("serialize-framerate")); 180 | } 181 | newParams += std::string(",type=disk,file=") + std::string(arguments.get("write-file")); 182 | 183 | serializerParams.parameters = newParams.c_str(); 184 | serializerParams.onData = nullptr; 185 | 186 | dwSensorSerializer_initialize(&serializer, &serializerParams, sensor); 187 | } 188 | //! [nv_docs_popoulate_params_and_call_initializer] 189 | 190 | std::cout << "Serializer created" << std::endl; 191 | } 192 | 193 | /*--------------------------------------------------------------------------*/ 194 | 195 | 196 | /* Read frames from every camera on the csi-port and add them to the image pool */ 197 | 198 | 199 | 200 | 201 | /*--------------------------------------------------------------------------*/ 202 | 203 | 204 | /* Start camera and serialization */ 205 | bool Camera::start() 206 | { 207 | if (record) { 208 | dwSensorSerializer_start(serializer); 209 | } 210 | return dwSensor_start(sensor) == DW_SUCCESS; 211 | } 212 | 213 | /*--------------------------------------------------------------------------*/ 214 | 215 | /* Stop the camera sensor and release all resources */ 216 | void Camera::stop_camera() 217 | { 218 | if (record) { 219 | dwSensorSerializer_stop(serializer); 220 | dwSensorSerializer_release(&serializer); 221 | } 222 | 223 | dwSensor_stop(sensor); 224 | 225 | for (auto frame : rgbaImagePool) { 226 | NvMediaImageDestroy(frame->img); 227 | delete frame; 228 | } 229 | 230 | dwImageFormatConverter_release(&converter); 231 | } 232 | 233 | 234 | Camera::~Camera() {} 235 | 236 | 237 | 238 | -------------------------------------------------------------------------------- /src/Camera.hpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2015-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | #include 36 | #include 37 | #include 38 | 39 | #include 40 | #include 41 | 42 | class Camera 43 | { 44 | 45 | public: 46 | Camera(dwSensorHandle_t &sensor, dwSensorParams sensorParams, dwSALHandle_t sal, dwContextHandle_t sdk, ProgramArguments arguments, bool record); 47 | ~Camera(); 48 | void stop_camera(); 49 | bool start(); 50 | //void capture_camera(); 51 | dwSensorHandle_t getSensor() { return sensor;} 52 | 53 | 54 | dwSensorHandle_t sensor; 55 | uint32_t numSiblings; 56 | uint32_t width; 57 | uint32_t height; 58 | dwImageStreamerHandle_t streamer; 59 | dwImageFormatConverterHandle_t converter; 60 | std::vector rgbaImagePool; 61 | dwSensorSerializerHandle_t serializer; 62 | dwImageType imageType; 63 | bool record; 64 | 65 | 66 | protected: 67 | void initImagePool(dwContextHandle_t sdk); 68 | void initFormatter(dwContextHandle_t sdk); 69 | void initSerializer(ProgramArguments arguments); 70 | 71 | }; 72 | -------------------------------------------------------------------------------- /src/Checks.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SAMPLES_COMMON_CHECKS_HPP__ 2 | #define SAMPLES_COMMON_CHECKS_HPP__ 3 | 4 | #include 5 | 6 | #include 7 | 8 | #include 9 | #include 10 | #include 11 | 12 | //------------------------------------------------------------------------------ 13 | // Functions 14 | //------------------------------------------------------------------------------ 15 | 16 | //------------------------------------------------------------------------------ 17 | // print GL error with location 18 | inline void getGLError(int line, const char *file, const char *function) 19 | { 20 | GLenum error = glGetError(); 21 | if (error != GL_NO_ERROR) { 22 | std::cerr << file << " in function " << function << " in line " << line << ": glError: 0x" 23 | << std::hex << error << std::dec << std::endl; 24 | exit(1); 25 | } 26 | } 27 | 28 | #ifndef __PRETTY_FUNCTION__ 29 | #define __PRETTY_FUNCTION__ __FUNCTION__ 30 | #endif 31 | 32 | // macro to easily check for GL errors 33 | #define CHECK_GL_ERROR() getGLError(__LINE__, __FILE__, __PRETTY_FUNCTION__); 34 | 35 | //------------------------------------------------------------------------------ 36 | // macro to easily check for dw errors 37 | #define CHECK_DW_ERROR(x) { \ 38 | dwStatus result = x; \ 39 | if(result!=DW_SUCCESS) \ 40 | throw std::runtime_error(std::string("DW Error ") \ 41 | + dwGetStatusName(result) \ 42 | + std::string(" executing DW function:\n " #x) \ 43 | + std::string("\n at " __FILE__ ":") + std::to_string(__LINE__)); \ 44 | }; 45 | 46 | //------------------------------------------------------------------------------ 47 | // macro to easily check for cuda errors 48 | #define CHECK_CUDA_ERROR(x) { \ 49 | x; \ 50 | auto result = cudaGetLastError(); \ 51 | if(result != cudaSuccess) \ 52 | throw std::runtime_error(std::string("CUDA Error ") \ 53 | + cudaGetErrorString(result) \ 54 | + std::string(" executing CUDA function:\n " #x) \ 55 | + std::string("\n at " __FILE__ ":") + std::to_string(__LINE__)); \ 56 | }; 57 | 58 | #endif // SAMPLES_COMMON_CHECKS_HPP__ 59 | -------------------------------------------------------------------------------- /src/ConsoleColor.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2015-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #define _CRT_SECURE_NO_WARNINGS 32 | 33 | #include "ConsoleColor.hpp" 34 | 35 | #ifdef WINDOWS 36 | #include 37 | #include 38 | #include 39 | #define isatty(x) _isatty(x) 40 | #define fileno(x) _fileno(x) 41 | #else 42 | #include 43 | #endif 44 | #include 45 | #include 46 | 47 | //------------------------------------------------------------------------------ 48 | bool shouldUseColor(bool streamIsTTY) { 49 | #ifdef WINDOWS 50 | // On Windows the TERM variable is usually not set, but the 51 | // console there does support colors. 52 | return streamIsTTY; 53 | #else 54 | // On non-Windows platforms, we rely on the TERM variable. 55 | const char* cterm = getenv("TERM"); 56 | if (cterm == nullptr) return false; 57 | std::string term(cterm); 58 | const bool termOk = 59 | (term == "xterm") || 60 | (term == "xterm-color") || 61 | (term == "xterm-256color") || 62 | (term == "screen") || 63 | (term == "screen-256color") || 64 | (term == "tmux") || 65 | (term == "tmux-256color") || 66 | (term == "rxvt-unicode") || 67 | (term == "rxvt-unicode-256color") || 68 | (term == "linux") || 69 | (term == "cygwin"); 70 | return streamIsTTY && termOk; 71 | #endif 72 | } 73 | 74 | //------------------------------------------------------------------------------ 75 | // Returns the ANSI color code for the given color. COLOR_DEFAULT is 76 | // an invalid input. 77 | const char* getAnsiColorCode(EConsoleColor color) { 78 | switch (color) { 79 | case COLOR_RED: return "1"; 80 | case COLOR_GREEN: return "2"; 81 | case COLOR_YELLOW: return "3"; 82 | default: return NULL; 83 | }; 84 | } 85 | 86 | //------------------------------------------------------------------------------ 87 | #ifdef WINDOWS 88 | // Returns the character attribute for the given color. 89 | WORD getColorAttribute(EConsoleColor color) { 90 | switch (color) { 91 | case COLOR_RED: return FOREGROUND_RED; 92 | case COLOR_GREEN: return FOREGROUND_GREEN; 93 | case COLOR_YELLOW: return FOREGROUND_RED | FOREGROUND_GREEN; 94 | default: return 0; 95 | } 96 | } 97 | #endif 98 | 99 | //------------------------------------------------------------------------------ 100 | void printColored(FILE *fd, EConsoleColor color, const char* msg) 101 | { 102 | bool useColor = (color != COLOR_DEFAULT); 103 | 104 | if(useColor) { 105 | useColor = shouldUseColor(isatty(fileno(fd)) != 0); 106 | } 107 | 108 | #ifdef WINDOWS 109 | HANDLE fdHandle = 0; 110 | if(useColor) { 111 | if (fd == stdout) 112 | fdHandle = GetStdHandle(STD_OUTPUT_HANDLE); 113 | else if (fd == stderr) 114 | fdHandle = GetStdHandle(STD_ERROR_HANDLE); 115 | else 116 | useColor = false; 117 | } 118 | #endif 119 | 120 | if (!useColor) { 121 | fprintf(fd, "%s", msg); 122 | return; 123 | } 124 | 125 | #ifdef WINDOWS 126 | // Gets the current text color. 127 | CONSOLE_SCREEN_BUFFER_INFO bufferInfo; 128 | GetConsoleScreenBufferInfo(fdHandle, &bufferInfo); 129 | const WORD oldAttrs = bufferInfo.wAttributes; 130 | 131 | // We need to flush the stream buffers into the console before each 132 | // SetConsoleTextAttribute call lest it affect the text that is already 133 | // printed but has not yet reached the console. 134 | fflush(fd); 135 | SetConsoleTextAttribute(fdHandle, 136 | getColorAttribute(color) | FOREGROUND_INTENSITY); 137 | fprintf(fd, msg); 138 | 139 | fflush(stdout); 140 | // Restores the text color. 141 | SetConsoleTextAttribute(fdHandle, oldAttrs); 142 | #else 143 | fprintf(fd, "\033[0;3%sm", getAnsiColorCode(color)); 144 | fprintf(fd, "%s", msg); 145 | fprintf(fd, "\033[m"); // Resets the terminal to default. 146 | #endif 147 | } 148 | 149 | //------------------------------------------------------------------------------ 150 | dwLogCallback getConsoleLoggerCallback(bool useColors, bool disableBuffering) 151 | { 152 | if(disableBuffering) 153 | setbuf(stdout, NULL); 154 | 155 | if (useColors) 156 | return [](dwContextHandle_t, dwLoggerVerbosity level, const char *msg) 157 | { 158 | EConsoleColor color = COLOR_DEFAULT; 159 | FILE *fd = stdout; 160 | switch (level) 161 | { 162 | case DW_LOG_VERBOSE: 163 | case DW_LOG_DEBUG: 164 | break; 165 | case DW_LOG_WARN: 166 | color = COLOR_YELLOW; 167 | break; 168 | case DW_LOG_ERROR: 169 | color = COLOR_RED; 170 | fd = stderr; 171 | break; 172 | } 173 | printColored(fd, color, msg); 174 | }; 175 | else 176 | return [](dwContextHandle_t, dwLoggerVerbosity, const char *msg) { printf("%s", msg); }; 177 | } 178 | -------------------------------------------------------------------------------- /src/ConsoleColor.hpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2015-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef SAMPLES_COMMON_CONSOLECOLOR_HPP__ 32 | #define SAMPLES_COMMON_CONSOLECOLOR_HPP__ 33 | 34 | #include 35 | #include 36 | 37 | enum EConsoleColor { 38 | COLOR_DEFAULT, 39 | COLOR_RED, 40 | COLOR_GREEN, 41 | COLOR_YELLOW 42 | }; 43 | 44 | void printColored(FILE *fd, EConsoleColor color, const char* msg); 45 | dwLogCallback getConsoleLoggerCallback(bool useColors, bool disableBuffering = false); 46 | 47 | #endif // SAMPLES_COMMON_CONSOLECOLOR_HPP__ 48 | -------------------------------------------------------------------------------- /src/ProgramArguments.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | 21 | // Copyright (c) 2014-2016 NVIDIA Corporation. All rights reserved. 22 | 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #include 32 | 33 | #include 34 | #include 35 | 36 | std::string ProgramArguments::m_empty(""); 37 | 38 | ProgramArguments::ProgramArguments(std::initializer_list options) 39 | { 40 | for (auto &&o : options) { 41 | arguments[o.option] = o.default_value; 42 | if (o.required) 43 | required_arguments.push_back(o.option); 44 | } 45 | } 46 | 47 | ProgramArguments::ProgramArguments(const std::vector& options) 48 | { 49 | for (auto &&o : options) { 50 | if (o.required) 51 | required_arguments.push_back(o.option); 52 | else 53 | arguments[o.option] = o.default_value; 54 | } 55 | } 56 | 57 | ProgramArguments::~ProgramArguments() 58 | { 59 | } 60 | 61 | bool ProgramArguments::parse(const int argc, const char **argv) 62 | { 63 | bool show_help = false; 64 | 65 | //std::cmatch match_results; 66 | for (int i = 1; i < argc; ++i) { 67 | std::string arg = argv[i]; 68 | std::size_t mnPos = arg.find("--"); 69 | 70 | // has -- 71 | if (mnPos != std::string::npos) { 72 | arg = arg.substr(mnPos + 2); 73 | 74 | std::string name; 75 | std::string value; 76 | 77 | std::size_t eqPos = arg.find_first_of("="); 78 | if (eqPos == std::string::npos || eqPos == 0 || eqPos >= arg.length() - 1) { 79 | show_help = true; 80 | continue; 81 | } 82 | 83 | name = arg.substr(0, eqPos); 84 | value = arg.substr(eqPos + 1); 85 | 86 | auto option_it = arguments.find(name); 87 | if (option_it != arguments.end()) { 88 | option_it->second = value; 89 | } else { 90 | arguments[name] = value; 91 | } 92 | } 93 | } 94 | 95 | // Show Help? 96 | if (show_help) { 97 | if (arguments.size() > 0) { 98 | printf("Options:\n%s\n", printList().c_str()); 99 | } 100 | else { 101 | printf("Run application without command line arguments.\n"); 102 | } 103 | return false; 104 | } 105 | 106 | // Check Required Arguments 107 | bool hasAllRequiredArguments = true; 108 | std::vector missing_required; 109 | for (std::string required_argument : required_arguments) { 110 | if (!has(required_argument.c_str())) { 111 | missing_required.push_back(required_argument); 112 | hasAllRequiredArguments = false; 113 | } 114 | } 115 | if (!hasAllRequiredArguments) { 116 | std::string missing_required_message; 117 | std::string example_usage; 118 | for (std::string required_argument : missing_required) { 119 | missing_required_message.append("\""); 120 | missing_required_message.append(required_argument); 121 | missing_required_message.append("\", "); 122 | 123 | example_usage.append(" --"); 124 | example_usage.append(required_argument); 125 | example_usage.append("="); 126 | } 127 | std::string executable = argv[0]; 128 | 129 | printf("ProgramArguments: Missing required arguments: %s e.g.\n\t%s %s\n", 130 | missing_required_message.c_str(), executable.c_str(), example_usage.c_str()); 131 | } 132 | 133 | return hasAllRequiredArguments; 134 | } 135 | 136 | const std::string &ProgramArguments::get(const char *name) const 137 | { 138 | auto it = arguments.find(name); 139 | if (it == arguments.end()) { 140 | printf("ProgramArguments: Missing argument '%s' requested\n", name); 141 | return ProgramArguments::m_empty; 142 | } else 143 | return it->second; 144 | } 145 | 146 | bool ProgramArguments::has(const char *name) const 147 | { 148 | auto it = arguments.find(name); 149 | if( it == arguments.end() ) 150 | return false; 151 | 152 | return it->second.length() > 0; 153 | } 154 | 155 | void ProgramArguments::addOption(const Option_t &newOption) 156 | { 157 | if (has(newOption.option.c_str())) 158 | throw std::runtime_error(std::string("ProgramArguments already contains the new option: ") + newOption.option); 159 | 160 | arguments[newOption.option] = newOption.default_value; 161 | if (newOption.required) 162 | required_arguments.push_back(newOption.option); 163 | } 164 | 165 | void ProgramArguments::set(const char *option, const char *value) 166 | { 167 | arguments[option] = value; 168 | } 169 | 170 | 171 | std::string ProgramArguments::printList() const 172 | { 173 | std::string list; 174 | 175 | for (auto arg : arguments) { 176 | list.append("--"); 177 | list.append(arg.first); 178 | list.append("="); 179 | list.append(arg.second); 180 | list.append("\n"); 181 | } 182 | 183 | return list; 184 | } 185 | 186 | std::string ProgramArguments::parameterString() const 187 | { 188 | std::string list; 189 | 190 | bool first = true; 191 | for (auto arg : arguments) { 192 | if (!first) 193 | list.append(","); 194 | list.append(arg.first); 195 | list.append("="); 196 | list.append(arg.second); 197 | first = false; 198 | } 199 | 200 | return list; 201 | } 202 | -------------------------------------------------------------------------------- /src/ProgramArguments.hpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2014-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef SAMPLES_COMMON_PROGRAMARGUMENTS_HPP__ 32 | #define SAMPLES_COMMON_PROGRAMARGUMENTS_HPP__ 33 | 34 | #include 35 | #include 36 | #include 37 | 38 | // EXAMPLE USECASE: 39 | // 40 | // ProgramArguments arguments( 41 | // { ProgramArguments::Option_t("optional_option", "with default value"), 42 | // ProgramArguments::Option_t("required_option") 43 | // } 44 | // ); 45 | // 46 | // if (!arguments.parse(argc, argv)) exit(0); // Exit if not all require arguments are provided 47 | // printf("Program Arguments:\n%s\n", arguments.printList()); 48 | // 49 | class ProgramArguments 50 | { 51 | public: 52 | struct Option_t { 53 | Option_t(const char *option_, const char *default_value_) 54 | { 55 | option = option_; 56 | default_value = default_value_; 57 | required = false; 58 | } 59 | 60 | Option_t(const char *option_) 61 | { 62 | option = option_; 63 | default_value = ""; 64 | required = true; 65 | } 66 | 67 | std::string option; 68 | std::string default_value; 69 | bool required; 70 | }; 71 | 72 | public: 73 | ProgramArguments() {} 74 | ProgramArguments(std::initializer_list options); 75 | ProgramArguments(const std::vector& options); 76 | ~ProgramArguments(); 77 | 78 | bool parse(const int argc, const char **argv); 79 | 80 | bool has(const char *name) const; 81 | void addOption(const Option_t &newOption); 82 | 83 | const std::string &get(const char *name) const; 84 | void set(const char* option, const char* vaule); 85 | 86 | std::string printList() const; 87 | 88 | std::string parameterString() const; 89 | 90 | private: 91 | static std::string m_empty; 92 | 93 | std::map arguments; 94 | std::vector required_arguments; 95 | }; 96 | 97 | #endif // SAMPLES_COMMON_PROGRAMARGUMENTS_HPP__ 98 | -------------------------------------------------------------------------------- /src/ResourceManager.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2015-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | 32 | #include 33 | #include 34 | #include 35 | #include 36 | #include "ResourceManager.hpp" 37 | 38 | ResourceManager::~ResourceManager() 39 | { 40 | releaseSAL(); 41 | 42 | releaseRenderer(); 43 | 44 | releaseDriveworks(); 45 | 46 | releaseSampleApp(); 47 | 48 | delete window; 49 | } 50 | 51 | dwStatus ResourceManager::initDriveworks() 52 | { 53 | dwStatus res = dwLogger_initialize(getConsoleLoggerCallback(true)); 54 | if (DW_SUCCESS != res) return res; 55 | 56 | // instantiate Driveworks SDK context 57 | dwContextParameters sdkParams = dwContextParameters(); 58 | 59 | #ifdef VIBRANTE 60 | //sdkParams.eglDisplay = gWindow->getEGLDisplay(); 61 | memset(&sdkParams, 0, sizeof(dwContextParameters)); 62 | #endif 63 | 64 | (void) window; 65 | 66 | return dwInitialize(&m_SDKHandle, DW_VERSION, &sdkParams); 67 | } 68 | 69 | dwStatus ResourceManager::initSAL() 70 | { 71 | return dwSAL_initialize(&m_salHandle, m_SDKHandle); 72 | } 73 | 74 | void ResourceManager::releaseSAL() 75 | { 76 | dwSAL_release(&m_salHandle); 77 | } 78 | 79 | dwStatus ResourceManager::initRenderer() 80 | { 81 | dwStatus result; 82 | 83 | result = dwRenderer_initialize(&m_rendererHandle, m_SDKHandle); 84 | if (result != DW_SUCCESS) 85 | throw std::runtime_error(std::string("Cannot init renderer: ") + 86 | dwGetStatusName(result)); 87 | 88 | // Set some renderer defaults 89 | dwRect rect; 90 | rect.width = window->width(); 91 | rect.height = window->height(); 92 | rect.x = 0; 93 | rect.y = 0; 94 | 95 | dwRenderer_setRect(rect, m_rendererHandle); 96 | 97 | float32_t rasterTransform[9]; 98 | rasterTransform[0] = 1.0f; 99 | rasterTransform[3] = 0.0f; 100 | rasterTransform[6] = 0.0f; 101 | 102 | rasterTransform[1] = 0.0f; 103 | rasterTransform[4] = 1.0f; 104 | rasterTransform[7] = 0.0f; 105 | 106 | rasterTransform[2] = 0.0f; 107 | rasterTransform[5] = 0.0f; 108 | rasterTransform[8] = 1.0f; 109 | 110 | result = dwRenderer_set2DTransform(rasterTransform, m_rendererHandle); 111 | if (DW_SUCCESS != result) return result; 112 | 113 | result = dwRenderer_setPointSize(4.0f, m_rendererHandle); 114 | if (DW_SUCCESS != result) return result; 115 | 116 | result = dwRenderer_setColor(DW_RENDERER_COLOR_GREEN, m_rendererHandle); 117 | if (DW_SUCCESS != result) return result; 118 | 119 | result = dwRenderer_setFont(DW_RENDER_FONT_VERDANA_16, m_rendererHandle); 120 | 121 | return result; 122 | } 123 | 124 | void ResourceManager::releaseDriveworks() 125 | { 126 | dwRelease(&m_SDKHandle); 127 | dwLogger_release(); 128 | } 129 | 130 | void ResourceManager::releaseRenderer() 131 | { 132 | dwRenderer_release(&m_rendererHandle); 133 | } 134 | 135 | std::string ResourceManager::getArgument(const char *name) const 136 | { 137 | return gArguments.get(name); 138 | } 139 | 140 | dwStatus ResourceManager::initializeResources(int argc, 141 | const char *argv[], 142 | const ProgramArguments* arguments, 143 | void (*userKeyPressCallback)(int)) 144 | { 145 | try { 146 | initSampleApp(argc, argv, arguments, userKeyPressCallback, 960, 604); 147 | } catch (const std::runtime_error& e) { 148 | std::cerr << e.what(); 149 | return DW_INTERNAL_ERROR; 150 | } 151 | 152 | dwStatus res = initDriveworks(); 153 | if(DW_SUCCESS != res) { 154 | std::cerr << "Cannot initialize DriveWorks" << std::endl; 155 | return res; 156 | } 157 | 158 | //res = initRenderer(); 159 | //if(DW_SUCCESS != res) { 160 | // std::cerr << "Cannot initialize DriveWorks' renderer" << std::endl; 161 | // return res; 162 | //} 163 | 164 | res = initSAL(); 165 | if(DW_SUCCESS != res) { 166 | std::cerr << "Cannot initialize SAL" << std::endl; 167 | return res; 168 | } 169 | 170 | 171 | return DW_SUCCESS; 172 | } 173 | 174 | void ResourceManager::setWindowSize(const int32_t width, const int32_t height) { 175 | window->setWindowSize(width, height); 176 | 177 | dwRect rect{0, 0, width, height}; 178 | dwRenderer_setRect(rect, m_rendererHandle); 179 | } 180 | -------------------------------------------------------------------------------- /src/ResourceManager.hpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2015-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef DRIVEWORKSSDK_RESOURCEMANAGER_HPP__ 32 | #define DRIVEWORKSSDK_RESOURCEMANAGER_HPP__ 33 | 34 | #include 35 | 36 | #include 37 | #include 38 | #include 39 | 40 | #include 41 | #include 42 | #include 43 | #include 44 | #include 45 | 46 | // Sample Framework 47 | #include 48 | 49 | /** 50 | * RAII Manager for the resources that are not the object of this sample 51 | **/ 52 | 53 | class ResourceManager 54 | { 55 | private: 56 | dwContextHandle_t m_SDKHandle; 57 | dwRendererHandle_t m_rendererHandle; 58 | dwSALHandle_t m_salHandle; 59 | 60 | protected: 61 | dwStatus initDriveworks(); 62 | dwStatus initSAL(); 63 | dwStatus initRenderer(); 64 | 65 | void releaseRenderer(); 66 | void releaseSAL(); 67 | void releaseDriveworks(); 68 | 69 | public: 70 | ResourceManager() 71 | : m_SDKHandle(DW_NULL_HANDLE) 72 | , m_rendererHandle(DW_NULL_HANDLE) 73 | , m_salHandle(DW_NULL_HANDLE) 74 | {} 75 | 76 | ~ResourceManager(); 77 | 78 | dwStatus initializeResources(int argc, 79 | const char *argv[], 80 | const ProgramArguments* arguments, 81 | void (*userKeyPressCallback)(int)) ; 82 | 83 | const dwContextHandle_t getSDK() const 84 | { 85 | return m_SDKHandle; 86 | } 87 | 88 | const dwRendererHandle_t getRenderer() const 89 | { 90 | return m_rendererHandle; 91 | } 92 | 93 | const dwSALHandle_t getSAL() const 94 | { 95 | return m_salHandle; 96 | } 97 | 98 | WindowBase * getWindow() 99 | { 100 | return window; 101 | } 102 | 103 | std::string getArgument(const char *name) const; 104 | 105 | void setWindowSize(const int32_t width, const int32_t height); 106 | WindowBase *window; 107 | 108 | }; 109 | 110 | #endif //DRIVEWORKSSDK_RESOURCEMANAGER_HPP__ 111 | -------------------------------------------------------------------------------- /src/SampleFramework.cpp: -------------------------------------------------------------------------------- 1 | #pragma GCC diagnostic ignored "-Wold-style-cast" 2 | 3 | #include 4 | #include // for memset 5 | #include 6 | 7 | #include 8 | 9 | void (*gUserKeyPressCallback)(int) = 0; 10 | ProgramArguments gArguments; 11 | WindowBase *gWindow = nullptr; 12 | bool gRun = false; 13 | 14 | void sig_int_handler(int sig) 15 | { 16 | (void)sig; 17 | 18 | gRun = false; 19 | } 20 | 21 | void keyPressCallback(int key) 22 | { 23 | // stop application 24 | if (key == GLFW_KEY_ESCAPE) 25 | gRun = false; 26 | 27 | if (gUserKeyPressCallback) 28 | { 29 | gUserKeyPressCallback(key); 30 | } 31 | } 32 | 33 | void drawLineSegments(const std::vector &segments, 34 | dwRenderBufferHandle_t renderBuffer, dwRendererHandle_t renderer) 35 | { 36 | float32_t* coords = nullptr; 37 | uint32_t maxVertices = 0; 38 | uint32_t vertexStride = 0; 39 | dwRenderBuffer_map(&coords, &maxVertices, &vertexStride, renderBuffer); 40 | 41 | dwRect screenRectangle; 42 | dwRenderer_getRect(&screenRectangle, renderer); 43 | 44 | for (uint32_t i = 0U; i < segments.size(); ++i) 45 | { 46 | // transform pixel coords into rendered rectangle 47 | float32_t x_start = static_cast(segments[i].a.x) - 0.5f; 48 | float32_t y_start = static_cast(segments[i].a.y) - 0.5f; 49 | float32_t x_end = static_cast(segments[i].b.x) - 0.5f; 50 | float32_t y_end = static_cast(segments[i].b.y) - 0.5f; 51 | 52 | coords[0] = x_start; 53 | coords[1] = y_start; 54 | coords += vertexStride; 55 | 56 | coords[0] = x_end; 57 | coords[1] = y_end; 58 | coords += vertexStride; 59 | } 60 | 61 | dwRenderBuffer_unmap(static_cast(segments.size() * 2), renderBuffer); 62 | 63 | dwRenderer_renderBuffer(renderBuffer, renderer); 64 | 65 | } 66 | 67 | void drawBoxes(const std::vector &boxes, const std::vector *boxIds, 68 | float32_t normalizationWidth, float32_t normalizationHeight, 69 | dwRenderBufferHandle_t renderBuffer, dwRendererHandle_t renderer) 70 | { 71 | if (boxes.size() == 0) 72 | return; 73 | 74 | bool renderText = boxIds && boxIds->size() == boxes.size(); 75 | dwRenderer_setFont(DW_RENDER_FONT_VERDANA_20, renderer); 76 | char idString[64]; 77 | 78 | float32_t* coords = nullptr; 79 | uint32_t maxVertices = 0; 80 | uint32_t vertexStride = 0; 81 | dwRenderBuffer_map(&coords, &maxVertices, &vertexStride, renderBuffer); 82 | 83 | uint32_t n_boxes = static_cast(boxes.size()); 84 | uint32_t n_verts = 8 * n_boxes; 85 | if (n_verts > maxVertices) 86 | { 87 | n_boxes = maxVertices / 8; 88 | n_verts = 8 * n_boxes; 89 | } 90 | 91 | dwRect screenRectangle; 92 | dwRenderer_getRect(&screenRectangle, renderer); 93 | float32_t screenWidth = static_cast(screenRectangle.width); 94 | float32_t screenHeight = static_cast(screenRectangle.height); 95 | 96 | for (uint32_t i = 0U; i < n_boxes; ++i) 97 | { 98 | // transform pixel coords into rendered rectangle 99 | float32_t x_start = static_cast(boxes[i].x) - 0.5f; 100 | float32_t y_start = static_cast(boxes[i].y) - 0.5f; 101 | float32_t x_end = static_cast(boxes[i].width) + x_start; 102 | float32_t y_end = static_cast(boxes[i].height) + y_start; 103 | 104 | coords[0] = x_start; 105 | coords[1] = y_start; 106 | coords += vertexStride; 107 | 108 | coords[0] = x_start; 109 | coords[1] = y_end; 110 | coords += vertexStride; 111 | 112 | coords[0] = x_start; 113 | coords[1] = y_end; 114 | coords += vertexStride; 115 | 116 | coords[0] = x_end; 117 | coords[1] = y_end; 118 | coords += vertexStride; 119 | 120 | coords[0] = x_end; 121 | coords[1] = y_end; 122 | coords += vertexStride; 123 | 124 | coords[0] = x_end; 125 | coords[1] = y_start; 126 | coords += vertexStride; 127 | 128 | coords[0] = x_end; 129 | coords[1] = y_start; 130 | coords += vertexStride; 131 | 132 | coords[0] = x_start; 133 | coords[1] = y_start; 134 | coords += vertexStride; 135 | 136 | if (renderText) 137 | { 138 | #ifndef _MSC_VER 139 | sprintf(idString, "%u", (*boxIds)[i]); 140 | #else 141 | sprintf_s(idString, "%u", (*boxIds)[i]); 142 | #endif 143 | dwRenderer_renderText(static_cast((x_start * screenWidth) / normalizationWidth), 144 | screenRectangle.height - 145 | static_cast((y_start * screenHeight) / normalizationHeight), 146 | idString, renderer); 147 | } 148 | } 149 | dwRenderBuffer_unmap(n_verts, renderBuffer); 150 | dwRenderer_renderBuffer(renderBuffer, renderer); 151 | } 152 | 153 | void drawBoxesWithLabels(const std::vector> &boxesWithLabels, 154 | float32_t normalizationWidth, float32_t normalizationHeight, 155 | dwRenderBufferHandle_t renderBuffer, dwRendererHandle_t renderer) 156 | { 157 | if (boxesWithLabels.size() == 0) 158 | return; 159 | 160 | dwRenderer_setFont(DW_RENDER_FONT_VERDANA_20, renderer); 161 | 162 | float32_t* coords = nullptr; 163 | uint32_t maxVertices = 0; 164 | uint32_t vertexStride = 0; 165 | dwRenderBuffer_map(&coords, &maxVertices, &vertexStride, renderBuffer); 166 | 167 | uint32_t n_boxes = static_cast(boxesWithLabels.size()); 168 | uint32_t n_verts = 8 * n_boxes; 169 | if (n_verts > maxVertices) 170 | { 171 | n_boxes = maxVertices / 8; 172 | n_verts = 8 * n_boxes; 173 | } 174 | 175 | dwRect screenRectangle; 176 | dwRenderer_getRect(&screenRectangle, renderer); 177 | float32_t screenWidth = static_cast(screenRectangle.width); 178 | float32_t screenHeight = static_cast(screenRectangle.height); 179 | 180 | for (uint32_t i = 0U; i < n_boxes; ++i) 181 | { 182 | std::pair boxClassIdPair = boxesWithLabels[i]; 183 | dwBox2D &box = boxClassIdPair.first; 184 | std::string classLabel = boxClassIdPair.second; 185 | // transform pixel coords into rendered rectangle 186 | float32_t x_start = static_cast(box.x) - 0.5f; 187 | float32_t y_start = static_cast(box.y) - 0.5f; 188 | float32_t x_end = static_cast(box.width) + x_start; 189 | float32_t y_end = static_cast(box.height) + y_start; 190 | 191 | coords[0] = x_start; 192 | coords[1] = y_start; 193 | coords += vertexStride; 194 | 195 | coords[0] = x_start; 196 | coords[1] = y_end; 197 | coords += vertexStride; 198 | 199 | coords[0] = x_start; 200 | coords[1] = y_end; 201 | coords += vertexStride; 202 | 203 | coords[0] = x_end; 204 | coords[1] = y_end; 205 | coords += vertexStride; 206 | 207 | coords[0] = x_end; 208 | coords[1] = y_end; 209 | coords += vertexStride; 210 | 211 | coords[0] = x_end; 212 | coords[1] = y_start; 213 | coords += vertexStride; 214 | 215 | coords[0] = x_end; 216 | coords[1] = y_start; 217 | coords += vertexStride; 218 | 219 | coords[0] = x_start; 220 | coords[1] = y_start; 221 | coords += vertexStride; 222 | 223 | dwRenderer_renderText(static_cast((x_start * screenWidth) / normalizationWidth), 224 | screenRectangle.height - 225 | static_cast((y_start * screenHeight) / normalizationHeight), 226 | classLabel.c_str(), renderer); 227 | } 228 | dwRenderBuffer_unmap(n_verts, renderBuffer); 229 | dwRenderer_renderBuffer(renderBuffer, renderer); 230 | } 231 | 232 | 233 | bool initSampleApp( int argc, const char **argv, 234 | const ProgramArguments* arguments, 235 | void (*userKeyPressCallback)(int), 236 | uint32_t width, uint32_t height) 237 | { 238 | gUserKeyPressCallback = userKeyPressCallback; 239 | 240 | #if (!WINDOWS) 241 | struct sigaction action = {}; 242 | action.sa_handler = sig_int_handler; 243 | 244 | sigaction(SIGHUP, &action, NULL); // controlling terminal closed, Ctrl-D 245 | sigaction(SIGINT, &action, NULL); // Ctrl-C 246 | sigaction(SIGQUIT, &action, NULL); // Ctrl-\, clean quit with core dump 247 | sigaction(SIGABRT, &action, NULL); // abort() called. 248 | sigaction(SIGTERM, &action, NULL); // kill command 249 | sigaction(SIGSTOP, &action, NULL); // kill command 250 | #endif 251 | 252 | if (arguments) 253 | { 254 | gArguments = *arguments; 255 | 256 | if (!gArguments.parse(argc, argv)) 257 | { 258 | exit(1); // Exit if not all require arguments are provided 259 | } 260 | 261 | std::string argumentString = gArguments.printList(); 262 | if (argumentString.size() > 0) { 263 | std::cout << "Program Arguments:\n" << argumentString << std::endl; 264 | } 265 | } 266 | gRun = true; 267 | 268 | // Setup Window for Output, initialize the GL and GLFW 269 | #ifdef VIBRANTE 270 | bool offscreen = false; 271 | if (gArguments.has("offscreen")) { 272 | const std::string offscreenString = gArguments.get("offscreen"); 273 | if (offscreenString.compare("")) { 274 | offscreen = std::stoi(offscreenString) ? true : false; 275 | } 276 | } 277 | if (offscreen) 278 | gWindow = new WindowOffscreenEGL(width, height); 279 | #endif 280 | try { 281 | gWindow = gWindow ? gWindow : new WindowGLFW(width, height); 282 | } 283 | catch (const std::exception &/*ex*/) { 284 | #ifdef VIBRANTE 285 | gWindow = new WindowOffscreenEGL(width, height); 286 | #else 287 | gWindow = nullptr; 288 | #endif 289 | } 290 | 291 | if (gWindow == nullptr) 292 | return false; 293 | 294 | gWindow->makeCurrent(); 295 | gWindow->setOnKeypressCallback(keyPressCallback); 296 | 297 | return true; 298 | } 299 | 300 | void releaseSampleApp() 301 | { 302 | // Shutdown 303 | delete gWindow; 304 | gWindow = nullptr; 305 | } 306 | -------------------------------------------------------------------------------- /src/SampleFramework.hpp: -------------------------------------------------------------------------------- 1 | #ifndef SAMPLES_COMMON_SAMPLEFRAMEWORK_HPP__ 2 | #define SAMPLES_COMMON_SAMPLEFRAMEWORK_HPP__ 3 | 4 | #include 5 | 6 | #include 7 | #ifdef VIBRANTE 8 | #include 9 | #else 10 | #endif 11 | 12 | #include 13 | #include 14 | 15 | #include 16 | #include // for memset 17 | #include 18 | 19 | #include 20 | 21 | //------------------------------------------------------------------------------ 22 | // Variables 23 | //------------------------------------------------------------------------------ 24 | 25 | extern void (*gUserKeyPressCallback)(int); 26 | extern ProgramArguments gArguments; 27 | extern WindowBase *gWindow; 28 | extern bool gRun; 29 | 30 | /// Specifies a 2D line segment from point a to point b, in floating point coordinates 31 | typedef struct { 32 | dwVector2f a; 33 | dwVector2f b; 34 | } dwLineSegment2Df; 35 | 36 | //------------------------------------------------------------------------------ 37 | // Functions 38 | //------------------------------------------------------------------------------ 39 | 40 | // signal handling 41 | //void sig_int_handler(int sig); 42 | 43 | // key press event 44 | //void keyPressCallback(int key); 45 | 46 | // draw line segment in 2D 47 | // Required renderbuffer with the following properties: 48 | // - Renderbuffer should be initialized with DW_RENDER_PRIM_LINELIST 49 | // - Expected position format: DW_RENDER_FORMAT_R32G32_FLOAT 50 | // - Expected position semantic: DW_RENDER_SEMANTIC_POS_XY 51 | void drawLineSegments(const std::vector &segments, 52 | dwRenderBufferHandle_t renderBuffer, dwRendererHandle_t renderer); 53 | 54 | // draw box 55 | // Required renderbuffer with the following properties: 56 | // - Renderbuffer should be initialized with DW_RENDER_PRIM_LINELIST 57 | // - Expected position format: DW_RENDER_FORMAT_R32G32_FLOAT 58 | // - Expected position semantic: DW_RENDER_SEMANTIC_POS_XY 59 | void drawBoxes(const std::vector &boxes, const std::vector *boxIds, 60 | float32_t normalizationWidth, float32_t normalizationHeight, 61 | dwRenderBufferHandle_t renderBuffer, dwRendererHandle_t renderer); 62 | 63 | // draw box with labels 64 | // Required renderbuffer with the following properties: 65 | // - Renderbuffer should be initialized with DW_RENDER_PRIM_LINELIST 66 | // - Expected position format: DW_RENDER_FORMAT_R32G32_FLOAT 67 | // - Expected position semantic: DW_RENDER_SEMANTIC_POS_XY 68 | void drawBoxesWithLabels(const std::vector > &boxesWithLabels, 69 | float32_t normalizationWidth, float32_t normalizationHeight, 70 | dwRenderBufferHandle_t renderBuffer, dwRendererHandle_t renderer); 71 | 72 | 73 | // init sample application 74 | bool initSampleApp(int argc, const char **argv, 75 | const ProgramArguments* arguments, 76 | void (*userKeyPressCallback)(int), 77 | uint32_t width, uint32_t height); 78 | 79 | void releaseSampleApp(); 80 | 81 | 82 | #endif // SAMPLES_COMMON_SAMPLEFRAMEWORK_HPP__ 83 | -------------------------------------------------------------------------------- /src/Window.hpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2014-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef SAMPLES_COMMON_WINDOW_HPP__ 32 | #define SAMPLES_COMMON_WINDOW_HPP__ 33 | 34 | #include 35 | #include 36 | 37 | class WindowBase 38 | { 39 | public: 40 | 41 | typedef void (*KeyPressCallback)(int key); 42 | typedef void (*MouseDownCallback)(int button, float x, float y); 43 | typedef void (*MouseUpCallback)(int button, float x, float y); 44 | typedef void (*MouseMoveCallback)(float x, float y); 45 | typedef void (*MouseWheelCallback)(float dx, float dy); 46 | typedef void (*ResizeWindowCallback)(int width, int height); 47 | 48 | 49 | // create an X11 window 50 | // width: width of window 51 | // height: height of window 52 | WindowBase(int windowWidth, int windowHeight) 53 | : m_width(windowWidth) 54 | , m_height(windowHeight) 55 | , m_keyPressCallback(nullptr) 56 | , m_mouseDownCallback(nullptr) 57 | , m_mouseUpCallback(nullptr) 58 | , m_mouseMoveCallback(nullptr) 59 | , m_mouseWheelCallback(nullptr) 60 | , m_resizeWindowCallback(nullptr) 61 | { 62 | } 63 | 64 | // release window 65 | virtual ~WindowBase() 66 | { 67 | } 68 | 69 | // swap back and front buffers 70 | virtual bool swapBuffers() = 0; 71 | 72 | // reset EGL context 73 | virtual void resetContext() = 0; 74 | 75 | // make window context current to the calling thread 76 | virtual bool makeCurrent() = 0; 77 | 78 | // remove current window context from the calling thread 79 | virtual bool resetCurrent() = 0; 80 | 81 | // indicate that a window should be closed, i.e. requested by the user 82 | virtual bool shouldClose() { return false; } 83 | 84 | // Set the window size 85 | virtual bool setWindowSize(int w, int h) { (void)w; (void)h; return false; } 86 | 87 | // get EGL display 88 | virtual EGLDisplay getEGLDisplay(void) = 0; 89 | virtual EGLContext getEGLContext(void) = 0; 90 | 91 | int width() const { return m_width; } 92 | int height() const { return m_height; } 93 | 94 | void setOnKeypressCallback(KeyPressCallback callback) 95 | { 96 | m_keyPressCallback = callback; 97 | } 98 | 99 | void setOnMouseDownCallback(MouseDownCallback callback) 100 | { 101 | m_mouseDownCallback = callback; 102 | } 103 | 104 | void setOnMouseUpCallback(MouseUpCallback callback) 105 | { 106 | m_mouseUpCallback = callback; 107 | } 108 | 109 | void setOnMouseMoveCallback(MouseMoveCallback callback) 110 | { 111 | m_mouseMoveCallback = callback; 112 | } 113 | 114 | void setOnMouseWheelCallback(MouseWheelCallback callback) 115 | { 116 | m_mouseWheelCallback = callback; 117 | } 118 | 119 | void setOnResizeWindowCallback(ResizeWindowCallback callback) 120 | { 121 | m_resizeWindowCallback = callback; 122 | } 123 | 124 | protected: 125 | int m_width; 126 | int m_height; 127 | 128 | KeyPressCallback m_keyPressCallback; 129 | MouseDownCallback m_mouseDownCallback; 130 | MouseUpCallback m_mouseUpCallback; 131 | MouseMoveCallback m_mouseMoveCallback; 132 | MouseWheelCallback m_mouseWheelCallback; 133 | ResizeWindowCallback m_resizeWindowCallback; 134 | }; 135 | 136 | #endif // SAMPLES_COMMON_WINDOW_HPP__ 137 | -------------------------------------------------------------------------------- /src/WindowEGL.hpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2014-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef SAMPLES_COMMON_WINDOWEGL_HPP__ 32 | #define SAMPLES_COMMON_WINDOWEGL_HPP__ 33 | 34 | #include 35 | #include 36 | 37 | #include "Window.hpp" 38 | #include 39 | 40 | /** 41 | * @brief The EGLDisplay class 42 | */ 43 | class WindowOffscreenEGL : public WindowBase 44 | { 45 | public: 46 | WindowOffscreenEGL(int width, int height); 47 | virtual ~WindowOffscreenEGL(); 48 | 49 | EGLDisplay getEGLDisplay() override 50 | { 51 | return m_display; 52 | } 53 | EGLContext getEGLContext() override 54 | { 55 | return m_context; 56 | } 57 | EGLConfig getEGLConfig() const 58 | { 59 | return m_config; 60 | } 61 | 62 | bool makeCurrent() override; 63 | bool resetCurrent() override; 64 | bool swapBuffers() override; 65 | void resetContext() override; 66 | 67 | protected: 68 | bool initDrm(const char *name, EGLAttrib *layerAttribs, int &dispWidth, int &dispHeight); 69 | 70 | EGLDisplay m_display; 71 | EGLContext m_context; 72 | EGLConfig m_config; 73 | EGLSurface m_surface; 74 | EGLStreamKHR m_stream; 75 | 76 | bool m_offscreen; 77 | }; 78 | 79 | #endif // SAMPLES_COMMON_WINDOWEGL_HPP__ 80 | -------------------------------------------------------------------------------- /src/WindowGLFW.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2014-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #include "WindowGLFW.hpp" 32 | 33 | #include 34 | #include 35 | 36 | 37 | 38 | // ----------------------------------------------------------------------------- 39 | WindowGLFW::WindowGLFW(int width, int height, bool invisible) 40 | : WindowBase(width, height) 41 | { 42 | /* if (glfwInit() == 0) { 43 | std::cout << "WindowGLFW: Failed initialize GLFW " << std::endl; 44 | throw std::exception(); 45 | } 46 | 47 | // Create a windowed mode window and its OpenGL context 48 | glfwWindowHint(GLFW_RESIZABLE, GL_TRUE); 49 | glfwWindowHint(GLFW_SAMPLES, 0); // Disable MSAA 50 | glfwWindowHint(GLFW_DEPTH_BITS, 24); // Enable 51 | 52 | if (invisible) { 53 | glfwWindowHint(GLFW_VISIBLE, GL_FALSE); 54 | } 55 | 56 | #ifdef _GLESMODE 57 | glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_ES_API); 58 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 3); 59 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); 60 | #else 61 | glfwWindowHint(GLFW_CLIENT_API, GLFW_OPENGL_API); 62 | glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); 63 | glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 3); 64 | #endif 65 | 66 | m_hWindow = glfwCreateWindow(width, height, "GLFW", NULL, NULL); 67 | 68 | if (!m_hWindow) { 69 | glfwTerminate(); 70 | std::cout << "WindowGLFW: Failed create window" << std::endl; 71 | throw std::exception(); 72 | } 73 | 74 | glfwMakeContextCurrent(m_hWindow); 75 | 76 | #ifdef USE_GLEW 77 | // dwRenderer requires glewExperimental 78 | // because it calls glGenVertexArrays() 79 | glewExperimental = GL_TRUE; 80 | GLenum err = glewInit(); 81 | if (err != GLEW_OK) { 82 | glfwDestroyWindow(m_hWindow); 83 | glfwTerminate(); 84 | std::cout << "WindowGLFW: Failed to init GLEW: " << glewGetErrorString(err) << std::endl; 85 | throw std::exception(); 86 | } 87 | glGetError(); // clears error on init 88 | #endif 89 | 90 | // No vsync 91 | glfwSwapInterval(0); 92 | 93 | glfwSetInputMode(m_hWindow, GLFW_STICKY_KEYS, GL_FALSE); 94 | 95 | //Callbacks 96 | glfwSetWindowUserPointer(m_hWindow, this); 97 | glfwSetKeyCallback(m_hWindow, [](GLFWwindow *win, int key, int scancode, int action, int mods) { 98 | WindowGLFW *window = reinterpret_cast(glfwGetWindowUserPointer(win)); 99 | window->onKeyCallback(key, scancode, action, mods); 100 | }); 101 | glfwSetMouseButtonCallback(m_hWindow, [](GLFWwindow *win, int button, int action, int mods) { 102 | WindowGLFW *window = reinterpret_cast(glfwGetWindowUserPointer(win)); 103 | window->onMouseButtonCallback(button, action, mods); 104 | }); 105 | glfwSetCursorPosCallback(m_hWindow, [](GLFWwindow *win, double x, double y) { 106 | WindowGLFW *window = reinterpret_cast(glfwGetWindowUserPointer(win)); 107 | window->onMouseMoveCallback(x, y); 108 | }); 109 | glfwSetScrollCallback(m_hWindow, [](GLFWwindow *win, double dx, double dy) { 110 | WindowGLFW *window = reinterpret_cast(glfwGetWindowUserPointer(win)); 111 | window->onMouseWheelCallback(dx, dy); 112 | }); 113 | glfwSetFramebufferSizeCallback(m_hWindow, [](GLFWwindow *win, int width, int height) { 114 | WindowGLFW *window = reinterpret_cast(glfwGetWindowUserPointer(win)); 115 | window->onResizeWindowCallback(width, height); 116 | }); 117 | */ 118 | } 119 | 120 | // ----------------------------------------------------------------------------- 121 | WindowGLFW::~WindowGLFW(void) 122 | { 123 | // glfwDestroyWindow(m_hWindow); 124 | // glfwTerminate(); 125 | } 126 | 127 | 128 | // ----------------------------------------------------------------------------- 129 | EGLDisplay WindowGLFW::getEGLDisplay(void) 130 | { 131 | //#ifdef VIBRANTE 132 | // return glfwGetEGLDisplay(); 133 | //#else 134 | // return 0; 135 | //#endif 136 | } 137 | 138 | // ----------------------------------------------------------------------------- 139 | EGLContext WindowGLFW::getEGLContext(void) 140 | { 141 | //#ifdef VIBRANTE 142 | // return glfwGetEGLContext(m_hWindow); 143 | //#else 144 | // return 0; 145 | //#endif 146 | } 147 | 148 | // ----------------------------------------------------------------------------- 149 | void WindowGLFW::onKeyCallback(int key, int scancode, int action, int mods) 150 | { 151 | /* if (!m_keyPressCallback) 152 | return; 153 | 154 | (void)mods; 155 | (void)scancode; 156 | (void)action; 157 | 158 | if (action == GLFW_PRESS && mods == 0) 159 | m_keyPressCallback(key); 160 | */ 161 | } 162 | 163 | // ----------------------------------------------------------------------------- 164 | void WindowGLFW::onMouseButtonCallback(int button, int action, int mods) 165 | { 166 | /* (void)mods; 167 | 168 | double x, y; 169 | glfwGetCursorPos(m_hWindow, &x, &y); 170 | if (action == GLFW_PRESS) { 171 | if (!m_mouseDownCallback) 172 | return; 173 | m_mouseDownCallback(button, (float)x, (float)y); 174 | } else if (action == GLFW_RELEASE) { 175 | if (!m_mouseUpCallback) 176 | return; 177 | m_mouseUpCallback(button, (float)x, (float)y); 178 | } 179 | */ 180 | } 181 | 182 | // ----------------------------------------------------------------------------- 183 | void WindowGLFW::onMouseMoveCallback(double x, double y) 184 | { 185 | /* if (!m_mouseMoveCallback) 186 | return; 187 | m_mouseMoveCallback((float)x, (float)y); 188 | */ 189 | } 190 | 191 | // ----------------------------------------------------------------------------- 192 | void WindowGLFW::onMouseWheelCallback(double dx, double dy) 193 | { 194 | /* if (!m_mouseWheelCallback) 195 | return; 196 | m_mouseWheelCallback((float)dx, (float)dy); 197 | */ 198 | } 199 | 200 | // ----------------------------------------------------------------------------- 201 | void WindowGLFW::onResizeWindowCallback(int width, int height) 202 | { 203 | /* m_width = width; 204 | m_height = height; 205 | 206 | if (!m_resizeWindowCallback) 207 | return; 208 | m_resizeWindowCallback(width, height); 209 | */ 210 | } 211 | 212 | // ----------------------------------------------------------------------------- 213 | bool WindowGLFW::swapBuffers(void) 214 | { 215 | /* glfwPollEvents(); 216 | glfwSwapBuffers(m_hWindow); 217 | return true; 218 | */ 219 | } 220 | 221 | // ----------------------------------------------------------------------------- 222 | void WindowGLFW::resetContext() 223 | { 224 | } 225 | 226 | // ----------------------------------------------------------------------------- 227 | bool WindowGLFW::makeCurrent() 228 | { 229 | // Make the window's context current 230 | // glfwMakeContextCurrent(m_hWindow); 231 | 232 | return true; 233 | } 234 | 235 | // ----------------------------------------------------------------------------- 236 | bool WindowGLFW::resetCurrent() 237 | { 238 | //glfwMakeContextCurrent(nullptr); 239 | 240 | return true; 241 | } 242 | 243 | // ----------------------------------------------------------------------------- 244 | bool WindowGLFW::setWindowSize(int width, int height) 245 | { 246 | // Set the window size 247 | //glfwSetWindowSize(m_hWindow, width, height); 248 | return true; 249 | } 250 | -------------------------------------------------------------------------------- /src/WindowGLFW.hpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2014-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #ifndef SAMPLES_COMMON_WINDOWGLFW_HPP__ 32 | #define SAMPLES_COMMON_WINDOWGLFW_HPP__ 33 | 34 | #include "Window.hpp" 35 | 36 | #ifdef VIBRANTE 37 | #define GLFW_INCLUDE_ES3 38 | #define GLFW_EXPOSE_NATIVE_X11 39 | #define GLFW_EXPOSE_NATIVE_EGL 40 | #endif 41 | #include 42 | 43 | class WindowGLFW : public WindowBase 44 | { 45 | public: 46 | // create an X11 window 47 | // width: width of window 48 | // height: height of window 49 | WindowGLFW(int width, int height, bool invisible = false); 50 | 51 | // release window 52 | ~WindowGLFW(); 53 | 54 | // swap back and front buffers - return false if failed, i.e. window need close 55 | bool swapBuffers(); 56 | 57 | // reset EGL context 58 | void resetContext(); 59 | 60 | // make window context current to the calling thread 61 | bool makeCurrent(); 62 | 63 | // remove current window context from the calling thread 64 | bool resetCurrent(); 65 | 66 | bool shouldClose() override {return false;/* return glfwWindowShouldClose(m_hWindow) != 0; */} 67 | 68 | // Set the window size 69 | bool setWindowSize(int width, int height); 70 | 71 | // get EGL display 72 | EGLDisplay getEGLDisplay(void); 73 | EGLContext getEGLContext(void); 74 | 75 | void onKeyCallback(int key, int scancode, int action, int mods); 76 | void onMouseButtonCallback(int button, int action, int mods); 77 | void onMouseMoveCallback(double x, double y); 78 | void onMouseWheelCallback(double dx, double dy); 79 | void onResizeWindowCallback(int width, int height); 80 | 81 | protected: 82 | GLFWwindow *m_hWindow; 83 | }; 84 | 85 | #endif // SAMPLES_COMMON_WINDOWGLFW_HPP__ 86 | -------------------------------------------------------------------------------- /src/cv_connection.cpp: -------------------------------------------------------------------------------- 1 | #include "cv_connection.hpp" 2 | 3 | #include 4 | #include 5 | #include 6 | 7 | #include 8 | #include 9 | 10 | #include 11 | #include 12 | 13 | OpenCVConnector::OpenCVConnector(std::string topic_name) : it(nh), counter(0) { 14 | pub = it.advertise(topic_name, 1); 15 | 16 | 17 | } 18 | 19 | 20 | void OpenCVConnector::WriteToOpenCV(unsigned char* buffer, int width, int height) { 21 | 22 | 23 | // create a cv::Mat from a dwImageNvMedia rgbaImage 24 | cv::Mat mat_img(cv::Size(width, height), CV_8UC4, buffer); 25 | 26 | cv::Mat converted;//=new cv::Mat(); 27 | 28 | cv::cvtColor(mat_img,converted,cv::COLOR_RGBA2RGB); //=COLOR_BGRA2BGR 29 | 30 | cv_bridge::CvImage img_bridge; 31 | sensor_msgs::Image img_msg; // >> message to be sent 32 | 33 | std_msgs::Header header; // empty header 34 | header.seq = counter; // user defined counter 35 | header.stamp = ros::Time::now(); // time 36 | img_bridge = cv_bridge::CvImage(header, sensor_msgs::image_encodings::RGB8, converted); 37 | img_bridge.toImageMsg(img_msg); // from cv_bridge to sensor_msgs::Image 38 | pub.publish(img_msg); // ros::Publisher pub_img = node.advertise("topic", queuesize); 39 | 40 | } 41 | 42 | 43 | -------------------------------------------------------------------------------- /src/cv_connection.hpp: -------------------------------------------------------------------------------- 1 | 2 | #ifndef OPEN_CV_CONNECTOR 3 | #define OPEN_CV_CONNECTOR 4 | 5 | #include 6 | #include 7 | #include 8 | 9 | 10 | class OpenCVConnector { 11 | 12 | public: 13 | OpenCVConnector(std::string topic_name); 14 | 15 | void WriteToOpenCV(unsigned char*, int, int); 16 | 17 | 18 | ros::NodeHandle nh; 19 | image_transport::ImageTransport it; 20 | image_transport::Publisher pub; 21 | std::string topic_name; 22 | 23 | unsigned int counter; 24 | 25 | }; 26 | 27 | 28 | 29 | #endif 30 | 31 | -------------------------------------------------------------------------------- /src/main.cpp: -------------------------------------------------------------------------------- 1 | ///////////////////////////////////////////////////////////////////////////////////////// 2 | // This code contains NVIDIA Confidential Information and is disclosed 3 | // under the Mutual Non-Disclosure Agreement. 4 | // 5 | // Notice 6 | // ALL NVIDIA DESIGN SPECIFICATIONS AND CODE ("MATERIALS") ARE PROVIDED "AS IS" NVIDIA MAKES 7 | // NO REPRESENTATIONS, WARRANTIES, EXPRESSED, IMPLIED, STATUTORY, OR OTHERWISE WITH RESPECT TO 8 | // THE MATERIALS, AND EXPRESSLY DISCLAIMS ANY IMPLIED WARRANTIES OF NONINFRINGEMENT, 9 | // MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE. 10 | // 11 | // NVIDIA Corporation assumes no responsibility for the consequences of use of such 12 | // information or for any infringement of patents or other rights of third parties that may 13 | // result from its use. No license is granted by implication or otherwise under any patent 14 | // or patent rights of NVIDIA Corporation. No third party distribution is allowed unless 15 | // expressly authorized by NVIDIA. Details are subject to change without notice. 16 | // This code supersedes and replaces all information previously supplied. 17 | // NVIDIA Corporation products are not authorized for use as critical 18 | // components in life support devices or systems without express written approval of 19 | // NVIDIA Corporation. 20 | // 21 | // Copyright (c) 2015-2016 NVIDIA Corporation. All rights reserved. 22 | // 23 | // NVIDIA Corporation and its licensors retain all intellectual property and proprietary 24 | // rights in and to this software and related documentation and any modifications thereto. 25 | // Any use, reproduction, disclosure or distribution of this software and related 26 | // documentation without an express license agreement from NVIDIA Corporation is 27 | // strictly prohibited. 28 | // 29 | ///////////////////////////////////////////////////////////////////////////////////////// 30 | 31 | #include 32 | #include 33 | #include 34 | 35 | #include 36 | #include 37 | #include 38 | 39 | #ifdef LINUX 40 | #include 41 | #include 42 | #endif 43 | 44 | #include 45 | #include 46 | #include 47 | #include 48 | #include 49 | #include 50 | 51 | #include 52 | #include 53 | #include 54 | //#include 55 | 56 | 57 | #include 58 | 59 | 60 | // SAMPLE COMMON 61 | #include 62 | #include 63 | #include 64 | #include 65 | #include 66 | #include 67 | 68 | 69 | // CORE 70 | #include 71 | #include 72 | 73 | // RENDERER 74 | #include 75 | 76 | // HAL 77 | #include 78 | #include 79 | #include 80 | 81 | // IMAGE 82 | #include 83 | #include 84 | #include 85 | 86 | 87 | #include "cv_connection.hpp" 88 | 89 | #include "Camera.hpp" 90 | 91 | //------------------------------------------------------------------------------ 92 | // Variables 93 | //------------------------------------------------------------------------------ 94 | static volatile bool g_run = true; 95 | static bool gTakeScreenshot = false; 96 | static int gScreenshotCount = 0; 97 | 98 | // 1KB should be plenty for data lines from any sensor 99 | // Actual size is returned during runtime 100 | #define MAX_EMBED_DATA_SIZE (1024 * 1024) 101 | NvMediaISCEmbeddedData sensorData; 102 | 103 | // Resource Manager 104 | ResourceManager gResources; 105 | uint32_t g_numCameras; 106 | 107 | //------------------------------------------------------------------------------ 108 | // Method declarations 109 | //------------------------------------------------------------------------------ 110 | int main(int argc, const char **argv); 111 | void initGL(WindowBase **window); 112 | void initSensors(dwSALHandle_t sal, std::vector &cameras); 113 | 114 | void runNvMedia_pipeline(WindowBase *window, dwRendererHandle_t renderer, dwContextHandle_t sdk, 115 | std::vector &cameras); 116 | 117 | void sig_int_handler(int sig); 118 | void sig_handler(int sig); 119 | void userKeyPressCallback(int key); 120 | 121 | //------------------------------------------------------------------------------ 122 | int main(int argc, const char **argv) 123 | { 124 | 125 | // Program arguments 126 | ProgramArguments arguments( 127 | { 128 | ProgramArguments::Option_t("type-ab", "ar0231-rccb"), 129 | ProgramArguments::Option_t("type-cd", "ar0231-rccb"), 130 | ProgramArguments::Option_t("type-ef", "ar0231-rccb"), 131 | ProgramArguments::Option_t("selector-mask", "1111"), 132 | ProgramArguments::Option_t("csi-port", "ab"), 133 | ProgramArguments::Option_t("cross-csi-sync", "0"), 134 | ProgramArguments::Option_t("offscreen", "0"), 135 | ProgramArguments::Option_t("write-file", ""), 136 | ProgramArguments::Option_t("serialize-type", "h264"), 137 | ProgramArguments::Option_t("serialize-bitrate", "8000000"), 138 | ProgramArguments::Option_t("serialize-framerate", "30"), 139 | ProgramArguments::Option_t("slave", "0"), 140 | ProgramArguments::Option_t("fifo-size", "3"), 141 | 142 | }); 143 | 144 | gResources.initializeResources(argc, argv, &arguments, userKeyPressCallback); 145 | std::vector cameras; 146 | 147 | // Set up linux signal handlers 148 | struct sigaction action; 149 | memset(&action, 0, sizeof(action)); 150 | action.sa_handler = sig_handler; 151 | 152 | sigaction(SIGHUP, &action, NULL); // controlling terminal closed, Ctrl-D 153 | sigaction(SIGINT, &action, NULL); // Ctrl-C 154 | sigaction(SIGQUIT, &action, NULL); // Ctrl-\, clean quit with core dump 155 | sigaction(SIGABRT, &action, NULL); // abort() called. 156 | sigaction(SIGTERM, &action, NULL); // kill command 157 | 158 | //Init 159 | g_run = true; 160 | 161 | //initGL(&window); 162 | 163 | // create HAL and camera 164 | uint32_t imageWidth; 165 | uint32_t imageHeight; 166 | dwImageType cameraImageType; 167 | 168 | initSensors(gResources.getSAL(), cameras); 169 | 170 | 171 | for (auto &camera : cameras) { 172 | if(camera.imageType != DW_IMAGE_NVMEDIA) 173 | { 174 | std::cerr << "Error: Expected nvmedia image type, received " 175 | << cameraImageType << " instead." << std::endl; 176 | exit(-1); 177 | } 178 | } 179 | 180 | // Allocate buffer for parsed embedded data 181 | sensorData.top.data = new uint8_t[MAX_EMBED_DATA_SIZE]; 182 | sensorData.bottom.data = new uint8_t[MAX_EMBED_DATA_SIZE]; 183 | sensorData.top.bufferSize = MAX_EMBED_DATA_SIZE; 184 | sensorData.bottom.bufferSize = MAX_EMBED_DATA_SIZE; 185 | 186 | 187 | runNvMedia_pipeline(gResources.getWindow(), gResources.getRenderer(), gResources.getSDK(), cameras); 188 | 189 | // release used objects in correct order 190 | for (auto &camera : cameras) 191 | dwSAL_releaseSensor(&camera.sensor); 192 | 193 | // todo - render release code has been commented out, since that one results in a stall 194 | // of the GMSL (nvmedia) pipeline. The issue is known and will be fixed in the future. 195 | //dwRenderer_release(&renderer); 196 | 197 | 198 | delete[] sensorData.top.data; 199 | delete[] sensorData.bottom.data; 200 | 201 | return 0; 202 | } 203 | 204 | 205 | //------------------------------------------------------------------------------ 206 | void initGL(WindowBase **window) 207 | { 208 | bool offscreen = atoi(gArguments.get("offscreen").c_str()) != 0; 209 | //#ifdef VIBRANTE 210 | // if (offscreen) 211 | // *window = new WindowOffscreenEGL(1280, 800); 212 | //#else 213 | (void)offscreen; 214 | //#endif 215 | 216 | if(!gResources.getWindow()) 217 | gResources.window = new WindowGLFW(1280, 800); 218 | 219 | (gResources.window)->makeCurrent(); 220 | (gResources.window)->setOnKeypressCallback(userKeyPressCallback); 221 | } 222 | 223 | 224 | //------------------------------------------------------------------------------ 225 | void initSensors(dwSALHandle_t sal, std::vector &cameras) 226 | { 227 | 228 | bool recordCamera = !gArguments.get("write-file").empty(); 229 | std::string selector = gArguments.get("selector-mask"); 230 | 231 | dwStatus result; 232 | 233 | // identify active ports 234 | int idx = 0; 235 | int cnt[3] = {0, 0, 0}; 236 | std::string port[3] = {"ab", "cd", "ef"}; 237 | for (size_t i = 0; i < selector.length() && i < 12; i++, idx++) { 238 | const char s = selector[i]; 239 | if (s == '1') { 240 | cnt[idx / 4]++; 241 | } 242 | } 243 | 244 | 245 | 246 | // how many cameras selected in a port 247 | g_numCameras = 0; 248 | for (size_t p = 0; p < 3; p++) { 249 | if (cnt[p] > 0) { 250 | std::string params; 251 | 252 | params += std::string("csi-port=") + port[p]; 253 | params += ",camera-type=" + gArguments.get((std::string("type-") + port[p]).c_str()); 254 | params += ",camera-count=4"; // when using the mask, just ask for a;ll cameras, mask will select properly 255 | 256 | if (selector.size() >= p*4) { 257 | params += ",camera-mask="+ selector.substr(p*4, std::min(selector.size() - p*4, size_t{4})); 258 | } 259 | 260 | params += ",slave=" + gArguments.get("slave"); 261 | params += ",cross-csi-sync=" + gArguments.get("cross-csi-sync"); 262 | params += ",fifo-size=" + gArguments.get("fifo-size"); 263 | params += ",output-format=yuv"; 264 | 265 | dwSensorHandle_t salSensor = DW_NULL_HANDLE; 266 | dwSensorParams salParams; 267 | salParams.parameters = params.c_str(); 268 | salParams.protocol = "camera.gmsl"; 269 | 270 | Camera *cam = new Camera(salSensor, salParams, gResources.getSAL(), gResources.getSDK(), gArguments, recordCamera); 271 | cameras.push_back(*cam); 272 | (g_numCameras) += cam->numSiblings; 273 | } 274 | } 275 | } 276 | 277 | 278 | 279 | //------------------------------------------------------------------------------ 280 | 281 | 282 | void runNvMedia_pipeline(WindowBase *window, dwRendererHandle_t renderer, dwContextHandle_t sdk, 283 | std::vector &cameras) 284 | { 285 | 286 | 287 | bool recordCamera = !gArguments.get("write-file").empty(); 288 | 289 | // Start all the cameras 290 | for (auto &camera : cameras) { 291 | g_run &= camera.start(); 292 | } 293 | 294 | 295 | 296 | 297 | int argc = 0; char** argv = nullptr; 298 | ros::init(argc, argv, "image_publisher"); 299 | 300 | 301 | std::vector cv_connectors; 302 | 303 | 304 | // Create a topic for each camera attached to each CSI port 305 | // Topic naming scheme is port/neighbor_idx/image 306 | for (int i = 0; i < cameras.size(); i++) { 307 | for (int neighbor = 0; neighbor < cameras[i].numSiblings; neighbor++) { 308 | const std::string topic = std::string("camera/") + std::to_string(i) + std::string("/") + std::to_string(neighbor) + std::string("/image"); 309 | cv_connectors.push_back(new OpenCVConnector(topic)); 310 | } 311 | } 312 | 313 | 314 | // Message msg; 315 | while (g_run && ros::ok()) { 316 | for (int i = 0; i < cameras.size(); i++) { 317 | Camera camera = cameras[i]; 318 | 319 | //Get Camera properties 320 | dwCameraProperties cameraProperties; 321 | dwSensorCamera_getSensorProperties(&cameraProperties, camera.sensor); 322 | 323 | for (int camIdx = i; camIdx < i + camera.numSiblings; camIdx++){ 324 | 325 | dwCameraFrameHandle_t frameHandle; 326 | dwImageNvMedia *frame = nullptr; 327 | dwStatus status = dwSensorCamera_readFrame(&frameHandle, camIdx, 1000000, camera.sensor); 328 | //Retrieve frames from multiple siblings?? 329 | //dwStatus status = dwSensorCamera_readFrame(&frameHandle, camera.numSiblings, 1000000, camera.sensor); 330 | if (status != DW_SUCCESS) { 331 | std::cout << "\n ERROR readFrame: " << dwGetStatusName(status) << std::endl; 332 | continue; 333 | } 334 | 335 | if( cameraProperties.outputTypes & DW_CAMERA_PROCESSED_IMAGE) { 336 | status = dwSensorCamera_getImageNvMedia(&frame, DW_CAMERA_PROCESSED_IMAGE, frameHandle); 337 | if( status != DW_SUCCESS ) { 338 | std::cout << "\n ERROR getImageNvMedia " << dwGetStatusName(status) << std::endl; 339 | } 340 | } 341 | 342 | 343 | // get embedded lines 344 | if( cameraProperties.outputTypes & DW_CAMERA_DATALINES) { 345 | const dwCameraDataLines* dataLines = nullptr; 346 | status = dwSensorCamera_getDataLines(&dataLines, frameHandle); 347 | // parse the data 348 | if( status == DW_SUCCESS ) { 349 | status = dwSensorCamera_parseDataNvMedia(&sensorData, dataLines, camera.sensor); 350 | if( status == DW_SUCCESS ) { 351 | std::cout << "Exposure Time (s): " << sensorData.exposureMidpointTime << "\r";// std::endl; 352 | } else { 353 | std::cout << "Could not parse embedded data: " << dwGetStatusName(status) << "\r"; //std::endl; 354 | } 355 | } else { 356 | std::cout << "Error getting datalines: " << dwGetStatusName(status) << "\r"; //std::endl; 357 | } 358 | } 359 | 360 | 361 | if (frame && recordCamera ) { 362 | dwSensorSerializer_serializeCameraFrameAsync(frameHandle, camera.serializer); 363 | } 364 | 365 | // log message 366 | //std::cout << frame->timestamp_us; 367 | //std::cout << " IMAGE SIZE " << frame->img->width << "x" << frame->img->height; 368 | //std::cout << std::endl; 369 | 370 | // Convert from YUV to RGBA 371 | if (frame && camera.rgbaImagePool.size() > 0) { 372 | dwImageNvMedia *rgbaImage = camera.rgbaImagePool.back(); 373 | camera.rgbaImagePool.pop_back(); 374 | 375 | //std::cout << " CONVERSION YUV->RGBA\n"; 376 | status = dwImageFormatConverter_copyConvertNvMedia(rgbaImage, frame, camera.converter); 377 | if (status != DW_SUCCESS) { 378 | std::cout << "\n ERROR copyConvert: " << dwGetStatusName(status) << std::endl; 379 | camera.rgbaImagePool.push_back(rgbaImage); 380 | 381 | } else { 382 | 383 | // take screenshot if requested 384 | if (true) 385 | { 386 | NvMediaImageSurfaceMap surfaceMap; 387 | if (NvMediaImageLock(rgbaImage->img, NVMEDIA_IMAGE_ACCESS_READ, &surfaceMap) == NVMEDIA_STATUS_OK) 388 | { 389 | 390 | cv_connectors[camIdx]->WriteToOpenCV((unsigned char*)surfaceMap.surface[0].mapping, rgbaImage->prop.width, rgbaImage->prop.height); 391 | /*char fname[128]; 392 | sprintf(fname, "screenshot_%04d.png", gScreenshotCount++); 393 | lodepng_encode32_file(fname, (unsigned char*)surfaceMap.surface[0].mapping, rgbaImage->prop.width, rgbaImage->prop.height); 394 | NvMediaImageUnlock(rgbaImage->img); 395 | gTakeScreenshot = false; 396 | std::cout << "SCREENSHOT TAKEN to " << fname << "\n";*/ 397 | NvMediaImageUnlock(rgbaImage->img); 398 | camera.rgbaImagePool.push_back(rgbaImage); 399 | 400 | }else 401 | { 402 | std::cout << "CANNOT LOCK NVMEDIA IMAGE - NO SCREENSHOT\n"; 403 | } 404 | } 405 | 406 | /* // Send via ImageStreamer to get GL image back 407 | status = dwImageStreamer_postNvMedia(rgbaImage, nvm2gl); 408 | if (status != DW_SUCCESS) { 409 | std::cout << "\n ERROR postNvMedia: " << dwGetStatusName(status) << std::endl; 410 | } else { 411 | dwImageGL *frameGL = nullptr; 412 | status = dwImageStreamer_receiveGL(&frameGL, 60000, nvm2gl); 413 | 414 | if (status == DW_SUCCESS && frameGL) { 415 | glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); 416 | 417 | // render received texture 418 | dwRenderer_renderTexture(frameGL->tex, frameGL->target, renderer); 419 | 420 | dwImageStreamer_returnReceivedGL(frameGL, nvm2gl); 421 | } 422 | } 423 | 424 | // any image returned back, we put back into the pool 425 | dwImageNvMedia *retimg = nullptr; 426 | dwImageStreamer_waitPostedNvMedia(&retimg, 33000, nvm2gl); 427 | 428 | if (retimg) 429 | rgbaImagePool.push_back(retimg); 430 | */ } 431 | } 432 | 433 | dwSensorCamera_returnFrame(&frameHandle); 434 | 435 | if (window) 436 | window->swapBuffers(); 437 | } 438 | } 439 | } 440 | 441 | // Clean up and release camera assets 442 | for (auto camera : cameras) { 443 | camera.stop_camera(); 444 | } 445 | 446 | } 447 | 448 | ////------------------------------------------------------------------------------ 449 | void sig_handler(int sig) 450 | { 451 | (void)sig; 452 | 453 | g_run = false; 454 | } 455 | 456 | ////------------------------------------------------------------------------------ 457 | void userKeyPressCallback(int key) 458 | { 459 | // stop application 460 | if (key == GLFW_KEY_ESCAPE) 461 | gRun = false; 462 | } 463 | 464 | 465 | --------------------------------------------------------------------------------