2015-01-09 07:31:09 +03:00
|
|
|
include (CMakeParseArguments)
|
2015-10-27 20:49:44 +03:00
|
|
|
include (Folders)
|
2015-01-09 07:31:09 +03:00
|
|
|
|
|
|
|
#
|
2015-10-27 20:49:44 +03:00
|
|
|
# add_bond_codegen (file.bond [file2.bond ...]
|
2015-01-09 07:31:09 +03:00
|
|
|
# [ENUM_HEADER]
|
2015-10-27 20:49:44 +03:00
|
|
|
# [OUTPUT_DIR dir]
|
2015-01-09 07:31:09 +03:00
|
|
|
# [IMPORT_DIR dir [dir2, ...]]
|
|
|
|
# [OPTIONS opt [opt2 ...]])
|
|
|
|
# [TARGET name]
|
|
|
|
#
|
|
|
|
function (add_bond_codegen)
|
2022-03-09 02:59:40 +03:00
|
|
|
set (flagArgs ENUM_HEADER)
|
2015-01-09 07:31:09 +03:00
|
|
|
set (oneValueArgs OUTPUT_DIR TARGET)
|
|
|
|
set (multiValueArgs IMPORT_DIR OPTIONS)
|
2015-10-27 20:49:44 +03:00
|
|
|
cmake_parse_arguments (arg "${flagArgs}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
2015-01-09 07:31:09 +03:00
|
|
|
set (options)
|
|
|
|
set (outputDir ${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR})
|
|
|
|
if (arg_OUTPUT_DIR)
|
|
|
|
set (outputDir ${arg_OUTPUT_DIR})
|
|
|
|
endif()
|
|
|
|
list (APPEND options --output-dir="${outputDir}")
|
2016-08-15 21:13:33 +03:00
|
|
|
list (APPEND options --import-dir="${BOND_IDL}")
|
2015-01-09 07:31:09 +03:00
|
|
|
foreach (dir ${arg_IMPORT_DIR})
|
|
|
|
list(APPEND options --import-dir="${dir}")
|
2015-10-27 20:49:44 +03:00
|
|
|
endforeach()
|
2015-01-09 07:31:09 +03:00
|
|
|
foreach (opt ${arg_OPTIONS})
|
|
|
|
list (APPEND options "${opt}")
|
|
|
|
endforeach()
|
|
|
|
if (arg_ENUM_HEADER)
|
|
|
|
list(APPEND options --enum-header)
|
|
|
|
endif()
|
|
|
|
set (inputs "${arg_UNPARSED_ARGUMENTS}")
|
|
|
|
set (outputs)
|
|
|
|
foreach (file ${inputs})
|
|
|
|
get_filename_component (name ${file} NAME_WE)
|
2015-10-27 20:49:44 +03:00
|
|
|
list (APPEND outputs
|
2015-01-09 07:31:09 +03:00
|
|
|
"${outputDir}/${name}_reflection.h"
|
|
|
|
"${outputDir}/${name}_types.h"
|
|
|
|
"${outputDir}/${name}_types.cpp"
|
|
|
|
"${outputDir}/${name}_apply.h"
|
|
|
|
"${outputDir}/${name}_apply.cpp"
|
|
|
|
)
|
|
|
|
if (arg_ENUM_HEADER)
|
|
|
|
list(APPEND outputs "${outputDir}/${name}_enum.h")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
2016-08-23 02:28:26 +03:00
|
|
|
# if BOND_GBC_PATH is not set we must add a dependency on the "gbc" target to build it
|
|
|
|
if (NOT BOND_GBC_PATH)
|
|
|
|
set(gbc "gbc")
|
|
|
|
elseif()
|
|
|
|
set(gbc "")
|
|
|
|
endif()
|
2015-01-09 07:31:09 +03:00
|
|
|
add_custom_command(
|
|
|
|
OUTPUT ${outputs}
|
|
|
|
COMMAND ${GBC_EXECUTABLE} c++ ${options} ${inputs}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
|
2016-08-23 02:28:26 +03:00
|
|
|
DEPENDS ${inputs} ${gbc} ${GBC_EXECUTABLE})
|
2015-01-09 07:31:09 +03:00
|
|
|
if (arg_TARGET)
|
|
|
|
add_custom_target (${arg_TARGET}
|
|
|
|
DEPENDS ${outputs}
|
|
|
|
SOURCES ${inputs})
|
2015-10-27 20:49:44 +03:00
|
|
|
add_target_to_folder(${arg_TARGET})
|
2015-01-09 07:31:09 +03:00
|
|
|
endif()
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#
|
|
|
|
# add_bond_executable (name
|
|
|
|
# [schem.bond [schema2.bond]]
|
2022-03-09 02:59:40 +03:00
|
|
|
# source.cpp [source2.cpp])
|
2015-01-09 07:31:09 +03:00
|
|
|
#
|
|
|
|
function (add_bond_executable target)
|
|
|
|
set (schemas)
|
|
|
|
set (sources)
|
2022-03-09 02:59:40 +03:00
|
|
|
cmake_parse_arguments (arg "" "" "" ${ARGN})
|
2015-01-09 07:31:09 +03:00
|
|
|
foreach (file ${ARGV})
|
|
|
|
get_filename_component (ext ${file} EXT)
|
|
|
|
if (ext STREQUAL ".bond")
|
|
|
|
get_filename_component (name ${file} NAME_WE)
|
|
|
|
list (APPEND schemas "${file}")
|
|
|
|
list (APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}_types.cpp")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if (schemas)
|
2017-03-31 01:48:00 +03:00
|
|
|
set (options)
|
|
|
|
add_bond_codegen (${schemas} ${options})
|
2015-01-09 07:31:09 +03:00
|
|
|
endif()
|
|
|
|
add_executable (${ARGV} ${sources})
|
2015-10-27 20:49:44 +03:00
|
|
|
add_target_to_folder(${target})
|
2015-01-09 07:31:09 +03:00
|
|
|
target_link_libraries (${target} PRIVATE
|
2015-10-27 20:49:44 +03:00
|
|
|
bond
|
2015-01-09 07:31:09 +03:00
|
|
|
bond_apply)
|
2015-10-27 20:49:44 +03:00
|
|
|
target_include_directories (${target} PRIVATE
|
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
2015-01-09 07:31:09 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR})
|
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#
|
|
|
|
# add_bond_test (name
|
|
|
|
# [schem.bond [schema2.bond]]
|
2016-11-14 20:31:49 +03:00
|
|
|
# source.cpp [source2.cpp]
|
2022-03-09 02:59:40 +03:00
|
|
|
# [BUILD_ONLY])
|
2015-01-09 07:31:09 +03:00
|
|
|
#
|
|
|
|
function (add_bond_test test)
|
2016-11-14 20:31:49 +03:00
|
|
|
set (flagArgs BUILD_ONLY)
|
|
|
|
cmake_parse_arguments (arg "${flagArgs}" "" "" ${ARGN})
|
|
|
|
list (REMOVE_ITEM ARGV BUILD_ONLY)
|
2015-01-09 07:31:09 +03:00
|
|
|
list (INSERT ARGV 1 EXCLUDE_FROM_ALL)
|
2017-02-09 05:41:35 +03:00
|
|
|
|
2015-01-09 07:31:09 +03:00
|
|
|
add_bond_executable (${ARGV})
|
|
|
|
add_dependencies (check ${test})
|
2016-11-14 20:31:49 +03:00
|
|
|
if (NOT arg_BUILD_ONLY)
|
|
|
|
add_test (
|
|
|
|
NAME ${test}
|
|
|
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
|
|
|
COMMAND ${test})
|
|
|
|
endif()
|
2015-01-09 07:31:09 +03:00
|
|
|
endfunction()
|
|
|
|
|
|
|
|
#
|
|
|
|
# add_bond_python_module (name
|
|
|
|
# [schem.bond [schema2.bond]]
|
|
|
|
# source.cpp [source2.cpp])
|
|
|
|
#
|
|
|
|
function (add_bond_python_module target)
|
|
|
|
set (schemas)
|
|
|
|
set (sources)
|
|
|
|
foreach (file ${ARGV})
|
|
|
|
get_filename_component (ext ${file} EXT)
|
|
|
|
if (ext STREQUAL ".bond")
|
|
|
|
get_filename_component (name ${file} NAME_WE)
|
|
|
|
list (APPEND schemas "${file}")
|
|
|
|
list (APPEND sources "${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}/${name}_types.cpp")
|
|
|
|
endif()
|
|
|
|
endforeach()
|
|
|
|
if (schemas)
|
|
|
|
add_bond_codegen (${schemas})
|
|
|
|
endif()
|
|
|
|
list (INSERT ARGV 1 EXCLUDE_FROM_ALL)
|
|
|
|
python_add_module (${ARGV} ${sources})
|
|
|
|
add_dependencies (check ${target})
|
2015-10-27 20:49:44 +03:00
|
|
|
add_target_to_folder(${target})
|
|
|
|
target_link_libraries (${target} PRIVATE
|
2015-01-09 07:31:09 +03:00
|
|
|
bond
|
2015-10-27 20:49:44 +03:00
|
|
|
bond_apply
|
2015-01-09 07:31:09 +03:00
|
|
|
${PYTHON_LIBRARIES}
|
|
|
|
${Boost_PYTHON_LIBRARY})
|
|
|
|
target_include_directories (${target} PRIVATE
|
|
|
|
${BOND_PYTHON_INCLUDE}
|
|
|
|
${WINDOWSSDK_PREFERRED_DIR}/Include
|
|
|
|
${WINDOWSSDK_PREFERRED_DIR}/Include/shared
|
2015-10-27 20:49:44 +03:00
|
|
|
${CMAKE_CURRENT_BINARY_DIR}/${CMAKE_CFG_INTDIR}
|
2015-01-09 07:31:09 +03:00
|
|
|
${CMAKE_CURRENT_SOURCE_DIR}
|
|
|
|
${PYTHON_INCLUDE_DIR})
|
|
|
|
target_compile_definitions (${target} PRIVATE
|
|
|
|
-DBOOST_PYTHON_STATIC_LIB)
|
|
|
|
endfunction()
|