diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 21180c046..8ead4b21c 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -59,29 +59,25 @@ macro(ncnn_add_layer class) # generate layer_declaration and layer_registry file if(WITH_LAYER_${name}) if(WITH_LAYER_${name}_${arch}) - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/layer_declaration.h + string(APPEND layer_declaration "extern Layer* ${class}_${arch}_layer_creator();\n") - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/layer_registry.h + string(APPEND layer_registry "#if NCNN_STRING\n{\"${class}\",${class}_${arch}_layer_creator},\n#else\n{${class}_${arch}_layer_creator},\n#endif\n") else() - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/layer_declaration.h + string(APPEND layer_declaration "extern Layer* ${class}_layer_creator();\n") - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/layer_registry.h + string(APPEND layer_registry "#if NCNN_STRING\n{\"${class}\",${class}_layer_creator},\n#else\n{${class}_layer_creator},\n#endif\n") endif() else() - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/layer_registry.h "#if NCNN_STRING\n{\"${class}\",0},\n#else\n{0},\n#endif\n") + string(APPEND layer_registry "#if NCNN_STRING\n{\"${class}\",0},\n#else\n{0},\n#endif\n") endif() # generate layer_type_enum file - file(APPEND ${CMAKE_CURRENT_BINARY_DIR}/layer_type_enum.h "${class} = ${__LAYER_TYPE_ENUM_INDEX},\n") + string(APPEND layer_type_enum "${class} = ${__LAYER_TYPE_ENUM_INDEX},\n") math(EXPR __LAYER_TYPE_ENUM_INDEX "${__LAYER_TYPE_ENUM_INDEX}+1") endmacro() -# create new -file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/layer_declaration.h) -file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/layer_registry.h) -file(REMOVE ${CMAKE_CURRENT_BINARY_DIR}/layer_type_enum.h) set(__LAYER_TYPE_ENUM_INDEX 0) # layer implementation @@ -148,6 +144,11 @@ ncnn_add_layer(Yolov3DetectionOutput) ncnn_add_layer(PSROIPooling) ncnn_add_layer(ROIAlign OFF) +# create new +configure_file(layer_declaration.h.in ${CMAKE_CURRENT_BINARY_DIR}/layer_declaration.h) +configure_file(layer_registry.h.in ${CMAKE_CURRENT_BINARY_DIR}/layer_registry.h) +configure_file(layer_type_enum.h.in ${CMAKE_CURRENT_BINARY_DIR}/layer_type_enum.h) + add_library(ncnn STATIC ${ncnn_SRCS}) if(NCNN_OPENMP AND OpenMP_CXX_FOUND) diff --git a/src/layer_declaration.h.in b/src/layer_declaration.h.in new file mode 100644 index 000000000..6ed5ac6f8 --- /dev/null +++ b/src/layer_declaration.h.in @@ -0,0 +1,5 @@ +// Layer Declaration header +// +// This file is auto-generated by cmake, don't edit it. + +@layer_declaration@ diff --git a/src/layer_registry.h.in b/src/layer_registry.h.in new file mode 100644 index 000000000..54fa0b518 --- /dev/null +++ b/src/layer_registry.h.in @@ -0,0 +1,5 @@ +// Layer Registry header +// +// This file is auto-generated by cmake, don't edit it. + +@layer_registry@ diff --git a/src/layer_type_enum.h.in b/src/layer_type_enum.h.in new file mode 100644 index 000000000..3766a1696 --- /dev/null +++ b/src/layer_type_enum.h.in @@ -0,0 +1,5 @@ +// Layer Type Enum header +// +// This file is auto-generated by cmake, don't edit it. + +@layer_type_enum@