1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136
|
#############################################################################
#
# ViSP, open source Visual Servoing Platform software.
# Copyright (C) 2005 - 2025 by Inria. All rights reserved.
#
# This software is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# See the file LICENSE.txt at the root directory of this source
# distribution for additional information about the GNU GPL.
#
# For using ViSP with software that can not be combined with the GNU
# GPL, please contact Inria about acquiring a ViSP Professional
# Edition License.
#
# See https://visp.inria.fr for more information.
#
# This software was developed at:
# Inria Rennes - Bretagne Atlantique
# Campus Universitaire de Beaulieu
# 35042 Rennes Cedex
# France
#
# If you have questions regarding the use of this file, please contact
# Inria at visp@inria.fr
#
# This file is provided AS IS with NO WARRANTY OF ANY KIND, INCLUDING THE
# WARRANTY OF DESIGN, MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.
#
# Description:
# ViSP Python bindings module
#
#############################################################################
set(json_config_file "{}")
set(json_config_file_path "${CMAKE_CURRENT_BINARY_DIR}/cmake_config.json")
# Paths to important directories
string(JSON json_config_file SET ${json_config_file} "xml_doc_path" "\"${VISP_DOC_DIR}/xml\"")
string(JSON json_config_file SET ${json_config_file} "build_dir" "\"${CMAKE_BINARY_DIR}\"")
string(JSON json_config_file SET ${json_config_file} "source_dir" "\"${CMAKE_SOURCE_DIR}\"")
# Add include directories to config file
set(json_include_dirs "[]")
set(include_dirs_count 0)
foreach(include_dir ${VISP_INCLUDE_DIRS})
string(JSON json_include_dirs SET ${json_include_dirs} "${include_dirs_count}" "\"${include_dir}\"")
MATH(EXPR include_dirs_count "${include_dirs_count}+1")
endforeach()
string(JSON json_config_file SET ${json_config_file} "include_dirs" "${json_include_dirs}")
# For each bound module, add its headers and dependencies to config file
set(json_modules "{}")
foreach(module ${python_bound_modules})
string(REPLACE "visp_" "" clean_module_name ${module})
string(JSON json_modules SET ${json_modules} ${clean_module_name} "{}")
# Get module headers
set(json_header_list "[]")
set(header_count 0)
foreach(module_header ${VISP_MODULE_${module}_HEADERS})
string(JSON json_header_list SET ${json_header_list} "${header_count}" "\"${module_header}\"")
MATH(EXPR header_count "${header_count}+1")
endforeach()
string(JSON json_modules SET ${json_modules} ${clean_module_name} "headers" "${json_header_list}")
# Get module dependencies
set(json_deps_list "[]")
set(dep_count 0)
foreach(dep ${VISP_MODULE_${module}_DEPS})
string(REPLACE "visp_" "" clean_dep ${dep})
string(JSON json_deps_list SET ${json_deps_list} "${dep_count}" "\"${clean_dep}\"")
MATH(EXPR dep_count "${dep_count}+1")
endforeach()
string(JSON json_modules SET ${json_modules} ${clean_module_name} "dependencies" "${json_deps_list}")
endforeach()
string(JSON json_config_file SET ${json_config_file} "modules" ${json_modules})
# Define platform specific macros
# These should be the same as those defined when compiling the visp libraries
# The impact will only be visible if the macros defined (or not) below appear in ViSP's headers
# See https://github.com/cpredef/predef/tree/master for compiler/OS specific #defines
set(json_defines "{}")
string(JSON json_defines SET ${json_defines} "__cplusplus" "${VISP_CXX_STANDARD}")
# Compiler
if(CMAKE_COMPILER_IS_GNUCXX AND NOT (MSVC AND CMAKE_COMPILER_IS_CLANGCXX))
string(REPLACE "." ";" GCC_VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET GCC_VERSION_LIST 0 GCC_MAJOR)
list(GET GCC_VERSION_LIST 1 GCC_MINOR)
list(GET GCC_VERSION_LIST 2 GCC_PATCH)
string(JSON json_defines SET ${json_defines} "__GNUC__" "${GCC_MAJOR}")
string(JSON json_defines SET ${json_defines} "__GNUC_MINOR__" "${GCC_MINOR}")
string(JSON json_defines SET ${json_defines} "__GNUC_PATCHLEVEL__" "${GCC_PATCH}")
endif()
if(CMAKE_COMPILER_IS_CLANGCXX)
string(REPLACE "." ";" CLANG_VERSION_LIST ${CMAKE_CXX_COMPILER_VERSION})
list(GET CLANG_VERSION_LIST 0 CLANG_MAJOR)
list(GET CLANG_VERSION_LIST 1 CLANG_MINOR)
list(GET CLANG_VERSION_LIST 2 CLANG_PATCH)
string(JSON json_defines SET ${json_defines} "__clang__" "1")
string(JSON json_defines SET ${json_defines} "__clang_major__" "${CLANG_MAJOR}")
string(JSON json_defines SET ${json_defines} "__clang_minor__" "${CLANG_MINOR}")
string(JSON json_defines SET ${json_defines} "__clang_patchlevel__" "${CLANG_PATCH}")
string(JSON json_defines SET ${json_defines} "__clang_version__" "${CMAKE_CXX_COMPILER_VERSION}")
endif()
if(MSVC)
string(JSON json_defines SET ${json_defines} "_MSC_VER" "${MSVC_VERSION}")
endif()
if(MINGW)
string(JSON json_defines SET ${json_defines} "__MINGW32__" "null")
endif()
# OS
if(WIN32)
string(JSON json_defines SET ${json_defines} "_WIN32" "null")
string(JSON json_defines SET ${json_defines} "DWORD" "\"uint64_t\"")
string(JSON json_defines SET ${json_defines} "WINAPI" "\"__stdcall\"")
string(JSON json_defines SET ${json_defines} "LPVOID" "\"void*\"")
endif()
if(UNIX)
string(JSON json_defines SET ${json_defines} "__linux__" "null")
string(JSON json_defines SET ${json_defines} "__unix__" "null")
string(JSON json_defines SET ${json_defines} "_unix" "null")
endif()
if(APPLE)
string(JSON json_defines SET ${json_defines} "__APPLE__" "null")
string(JSON json_defines SET ${json_defines} "__MACH__" "null")
endif()
string(JSON json_config_file SET ${json_config_file} "defines" ${json_defines})
file(WRITE ${json_config_file_path} "${json_config_file}")
|