Commit 48f10641 authored by John Parent's avatar John Parent
Browse files

overhaul cmake api

parent 935f5d8a
Pipeline #232645 passed with stages
in 24 minutes and 51 seconds
......@@ -102,7 +102,7 @@ function(_autopybind11_get_compiler_flags)
endfunction()
function(_autopybind11_get_sources)
set(PreProcessOneValueArgs YAML_INPUT CONFIG_INPUT DESTINATION GENERATED_SOURCES GENERATED_INDEXES)
set(PreProcessOneValueArgs WRAPPER_INPUT CONFIG_INPUT DESTINATION GENERATED_SOURCES GENERATED_INDEXES)
set(PYBIND_RUN_NAME ${ARGV0})
cmake_parse_arguments(PARSE_ARGV 1 PYBIND_RUN "" "${PreProcessOneValueArgs}" "")
if(PYBIND_RUN_CONFIG_INPUT AND EXISTS ${PYBIND_RUN_CONFIG_INPUT})
......@@ -111,7 +111,7 @@ function(_autopybind11_get_sources)
execute_process(
COMMAND
${AutoPyBind11_generator}
"-y" ${PYBIND_RUN_YAML_INPUT}
"-y" ${PYBIND_RUN_WRAPPER_INPUT}
"-o" ${PYBIND_RUN_DESTINATION}
"-g" ${CastXML_EXECUTABLE}
${CONFIG_FLAGS}
......@@ -131,13 +131,13 @@ function(autopybind11_add_module)
if(NOT DEFINED AutoPyBind11_generator)
message(FATAL_ERROR "autopybind11_fetch_build_pybind11 must be called first")
endif()
set(generateOneValueArgs YAML_INPUT CONFIG_INPUT DESTINATION NAMESPACE C_STD_FLAG GEN_ONLY NO_FORMAT CLANG_OPTIONS)
set(generateOneValueArgs WRAPPER_INPUT CONFIG_INPUT DESTINATION NAMESPACE C_STD_FLAG GEN_ONLY NO_FORMAT CLANG_OPTIONS)
set(generateMultiValueArgs LINK_LIBRARIES FILES INCLUDE_DIRS)
set(PYBIND_ADD_LIB_NAME ${ARGV0})
cmake_parse_arguments(PARSE_ARGV 1 PYBIND_ADD_LIB "" "${generateOneValueArgs}" "${generateMultiValueArgs}")
if(NOT PYBIND_ADD_LIB_YAML_INPUT)
message(FATAL_ERROR "YAML_INPUT must be specified")
if(NOT PYBIND_ADD_LIB_WRAPPER_INPUT)
message(FATAL_ERROR "WRAPPER_INPUT must be specified")
endif()
if(NOT PYBIND_ADD_LIB_LINK_LIBRARIES)
message(FATAL_ERROR "LINK_LIBRARIES must be specified")
......@@ -147,7 +147,7 @@ function(autopybind11_add_module)
endif()
_autopybind11_get_sources(
${PYBIND_ADD_LIB_NAME}
YAML_INPUT ${PYBIND_ADD_LIB_YAML_INPUT}
WRAPPER_INPUT ${PYBIND_ADD_LIB_WRAPPER_INPUT}
CONFIG_INPUT ${PYBIND_ADD_LIB_CONFIG_INPUT}
DESTINATION ${PYBIND_ADD_LIB_DESTINATION}
GENERATED_SOURCES PYBIND_ADD_LIB_FILES
......@@ -191,7 +191,7 @@ function(autopybind11_add_module)
wrapper_${PYBIND_ADD_LIB_NAME}.cpp
COMMAND
${AutoPyBind11_generator}
-y ${PYBIND_ADD_LIB_YAML_INPUT}
-y ${PYBIND_ADD_LIB_WRAPPER_INPUT}
"--module_name" ${PYBIND_ADD_LIB_NAME}
"-g" ${CastXML_EXECUTABLE}
"-cg" "${PYBIND_ADD_LIB_CONFIG_INPUT}"
......@@ -214,7 +214,7 @@ function(autopybind11_add_module)
wrapper_${PYBIND_ADD_LIB_NAME}.cpp
COMMAND
${AutoPyBind11_generator}
-y ${PYBIND_ADD_LIB_YAML_INPUT}
-y ${PYBIND_ADD_LIB_WRAPPER_INPUT}
"--module_name" ${PYBIND_ADD_LIB_NAME}
"-g" ${CastXML_EXECUTABLE}
"-o" ${PYBIND_ADD_LIB_DESTINATION}
......
......@@ -586,7 +586,7 @@ the pybind11 code and adds a library to CMake which contains the pybind11 code.,
This command should be written once for each ``wrapper_input.yml`` file in the repository.
The command has the following structure::
autopybind11_add_module(<name> YAML_INPUT <path_to>/wrapper_input.yml
autopybind11_add_module(<name> WRAPPER_INPUT <path_to>/wrapper_input.yml
DESTINATION <path_to_output>
LINK_LIBRARIES <library_1> <library_2>
[CONFIG_INPUT <path_to>/config.yml])
......@@ -596,7 +596,7 @@ to customize the templates used to create the pybind11 CPP code. The default te
can be found in `text_blocks.py`_
An example of the function invocation is here::
autopybind11_add_module("example" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
autopybind11_add_module("example" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES wrapper_example)
......
......@@ -6,6 +6,6 @@ autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
add_library(simpleLib simple.cxx)
set_property(TARGET simpleLib PROPERTY POSITION_INDEPENDENT_CODE ON)
target_compile_options(simpleLib PUBLIC "-std=c++11")
autopybind11_add_module("simpleTest" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
autopybind11_add_module("simpleTest" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES simpleLib)
......@@ -5,6 +5,6 @@ find_package(AutoPyBind11)
autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
add_library(simpleLib simple.cxx)
set_property(TARGET simpleLib PROPERTY POSITION_INDEPENDENT_CODE ON)
autopybind11_add_module("check_attributesModule" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
autopybind11_add_module("check_attributesModule" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES simpleLib)
......@@ -5,6 +5,6 @@ find_package(AutoPyBind11)
autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
add_library(simpleLib simple.cxx)
set_property(TARGET simpleLib PROPERTY POSITION_INDEPENDENT_CODE ON)
autopybind11_add_module("classAttributesTest" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
autopybind11_add_module("classAttributesTest" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES simpleLib)
add_library(simpleLib simple.cxx)
set_property(TARGET simpleLib PROPERTY POSITION_INDEPENDENT_CODE ON)
autopybind11_add_module("simpleTest" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
autopybind11_add_module("simpleTest" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES simpleLib)
add_library(uncommentsimpleLib simple.cxx)
set_property(TARGET uncommentsimpleLib PROPERTY POSITION_INDEPENDENT_CODE ON)
autopybind11_add_module("uncommentedTest" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
autopybind11_add_module("uncommentedTest" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/config.yml
LINK_LIBRARIES uncommentsimpleLib)
\ No newline at end of file
......@@ -5,6 +5,6 @@ find_package(AutoPyBind11)
autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
add_library(simpleLib simple.cxx)
set_property(TARGET simpleLib PROPERTY POSITION_INDEPENDENT_CODE ON)
autopybind11_add_module("complexTrampoline" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
autopybind11_add_module("complexTrampoline" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES simpleLib)
......@@ -16,7 +16,7 @@ target_include_directories(custom_names INTERFACE
${CMAKE_CURRENT_SOURCE_DIR})
autopybind11_add_module("custom_names_module"
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/config.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES custom_names
......
......@@ -6,7 +6,7 @@ target_include_directories(custom_mixed_namespace INTERFACE
${CUSTOM_NAMESPACE_INCLUDE_DIR})
autopybind11_add_module("custom_mixed_namespace_module"
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/config.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES custom_mixed_namespace
......
......@@ -6,7 +6,7 @@ target_include_directories(custom_python_namespace INTERFACE
${CUSTOM_NAMESPACE_INCLUDE_DIR})
autopybind11_add_module("custom_python_namespace_module"
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/config.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES custom_python_namespace
......
......@@ -10,7 +10,7 @@ target_include_directories(holder_types INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
set_property(TARGET holder_types PROPERTY POSITION_INDEPENDENT_CODE ON)
autopybind11_add_module(compliance_mod
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/holder_wrap.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/holder_wrap.yml
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/config.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES holder_types)
cmake_minimum_required(VERSION 3.15)
find_package(AutoPyBind11)
autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SOURCE_DIR})
add_library(deleted_assn INTERFACE)
target_sources(deleted_assn INTERFACE
event.h)
target_include_directories(deleted_assn INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
autopybind11_add_module(del_assn_op
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrp.yml
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/cnf.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES deleted_assn
)
......@@ -6,6 +6,6 @@ autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
add_library(simpleLib simple.cxx)
target_compile_options(simpleLib PUBLIC "--std=c++11")
set_property(TARGET simpleLib PROPERTY POSITION_INDEPENDENT_CODE ON)
autopybind11_add_module("deleted_constructor_module" YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
autopybind11_add_module("deleted_constructor_module" WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/simple_wrap.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES simpleLib)
......@@ -14,7 +14,7 @@ target_include_directories(noisy INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
autopybind11_add_module(denoise_mod
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper.yml
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/conf.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES noisy)
......
......@@ -14,7 +14,7 @@ autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
autopybind11_add_module(EigenRefMod
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES EigenRef
)
\ No newline at end of file
......@@ -13,7 +13,7 @@ target_include_directories(eigen_no_ref INTERFACE $ENV{Eigen_INCLUDE_DIR}
file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
autopybind11_add_module(toggle_eigen_ref
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
CONFIG_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/config.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES eigen_no_ref
......
......@@ -12,7 +12,7 @@ find_package(AutoPyBind11)
autopybind11_fetch_build_pybind11(PYBIND11_DIR ${PYBIND11_SRC_DIR})
autopybind11_add_module(enum_dep
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES enum_inst
)
......@@ -11,8 +11,8 @@ target_include_directories(mylib INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
set(EXTRA_INCLUDES ${CMAKE_CURRENT_SOURCE_DIR}/extra_inc)
autopybind11_add_module(myModule
YAML_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
autopybind11_add_module(myModule
WRAPPER_INPUT ${CMAKE_CURRENT_SOURCE_DIR}/wrapper_input.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES mylib
INCLUDE_DIRS ${EXTRA_INCLUDES}
......
......@@ -10,8 +10,8 @@ get_filename_component(EXTRA_INC_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR} DIRECTOR
add_library(mylib INTERFACE)
target_include_directories(mylib INTERFACE ${EXTRA_INC_SOURCE_DIR})
autopybind11_add_module(myModule
YAML_INPUT ${EXTRA_INC_SOURCE_DIR}/wrapper_input.yml
autopybind11_add_module(myModule
WRAPPER_INPUT ${EXTRA_INC_SOURCE_DIR}/wrapper_input.yml
DESTINATION ${CMAKE_CURRENT_BINARY_DIR}
LINK_LIBRARIES mylib
)
\ No newline at end of file
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment