CMakeLists.txt 2.4 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12
list(APPEND OPR_PARAM_DEFS_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/scripts/opr_param_defs.py)
set(OPR_PARAM_DEFS_SCRIPT ${CMAKE_CURRENT_SOURCE_DIR}/scripts/gen_param_defs.py)

set(OPR_PARAM_DEFS_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR}/include/)
file(MAKE_DIRECTORY ${OPR_PARAM_DEFS_OUT_DIR}/megdnn)
add_custom_command(
    OUTPUT
        ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_defs.h
        ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_json.h
    COMMAND ${PYTHON_EXECUTABLE} ${OPR_PARAM_DEFS_SCRIPT} ${OPR_PARAM_DEFS_SRCS}
        ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_defs.h
    COMMAND ${PYTHON_EXECUTABLE} ${OPR_PARAM_DEFS_SCRIPT} ${OPR_PARAM_DEFS_SRCS}
13
       tmp_unuse.log --write-cppjson ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_json.h
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
    DEPENDS ${OPR_PARAM_DEFS_SRCS} ${OPR_PARAM_DEFS_SCRIPT}
    VERBATIM
)

list(APPEND OPR_PARAM_DEFS_OUTS
    ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_defs.h
    ${OPR_PARAM_DEFS_OUT_DIR}/megdnn/opr_param_json.h
)
list(APPEND OPR_PARAM_DEFS_INC ${OPR_PARAM_DEFS_OUT_DIR})

set(OPR_PARAM_DEFS_OUT_DIR ${CMAKE_CURRENT_BINARY_DIR})
file(MAKE_DIRECTORY ${OPR_PARAM_DEFS_OUT_DIR}/src/common)
add_custom_command(
    OUTPUT
        ${OPR_PARAM_DEFS_OUT_DIR}/src/common/opr_param_defs_enumv.cuh
    COMMAND ${PYTHON_EXECUTABLE} ${OPR_PARAM_DEFS_SCRIPT}
        --enumv ${OPR_PARAM_DEFS_SRCS}
        ${OPR_PARAM_DEFS_OUT_DIR}/src/common/opr_param_defs_enumv.cuh
    DEPENDS ${OPR_PARAM_DEFS_SRCS} ${OPR_PARAM_DEFS_SCRIPT}
    VERBATIM
)

list(APPEND OPR_PARAM_DEFS_OUTS
    ${OPR_PARAM_DEFS_OUT_DIR}/src/common/opr_param_defs_enumv.cuh
)
list(APPEND OPR_PARAM_DEFS_INC ${OPR_PARAM_DEFS_OUT_DIR})


42
install(DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/include/megdnn DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h")
43 44 45

add_custom_target(_opr_param_defs DEPENDS ${OPR_PARAM_DEFS_OUTS})
add_library(opr_param_defs INTERFACE)
46 47 48 49 50 51 52 53 54
target_include_directories(opr_param_defs
    INTERFACE
        $<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>
)
foreach (INCPATH IN LISTS OPR_PARAM_DEFS_INC)
    target_include_directories(opr_param_defs
        INTERFACE $<BUILD_INTERFACE:${INCPATH}>
    )
endforeach()
55

56 57
add_dependencies(opr_param_defs _opr_param_defs)
install(TARGETS opr_param_defs EXPORT ${MGE_EXPORT_TARGETS})
58 59 60 61



if(MGE_WITH_TEST)
62
    if(NOT MGE_BUILD_IMPERATIVE_RT)
63 64
        add_subdirectory(test)
    endif()
65 66 67
endif()

add_subdirectory(src)
68 69

# install(TARGETS megdnn opr_param_defs libmkl EXPORT ${MGE_EXPORT_TARGETS})