You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
114 lines
3.3 KiB
114 lines
3.3 KiB
include(CMakeParseArguments)
|
|
|
|
# zadd_executable(
|
|
#
|
|
# # #################### 目标文件 #################
|
|
# TARGET
|
|
# ...
|
|
#
|
|
# # #################### 依赖 ####################
|
|
# DEPENDENCIES
|
|
# ...
|
|
#
|
|
# # #################### 头文件路径 ###############
|
|
# INCLUDE_DIRECTORIES
|
|
# ...
|
|
#
|
|
# # #################### 链接的第三方库 ############
|
|
# LINK_LIBRARIES
|
|
# ...
|
|
#
|
|
# # #################### 源文件 ##################
|
|
# SRC
|
|
# ...
|
|
# )
|
|
|
|
function(zadd_executable)
|
|
set(oneValueArgs NAME TARGET)
|
|
set(multiValueArgs
|
|
INSTALL
|
|
SRC
|
|
DEFINES
|
|
DEPENDENCIES
|
|
LINK_LIBRARIES
|
|
LINK_DIRECTORIES
|
|
INCLUDE_DIRECTORIES)
|
|
|
|
|
|
cmake_parse_arguments(ZADD_EXECUTABLE "${options}" "${oneValueArgs}" "${multiValueArgs}" ${ARGN})
|
|
|
|
message("=================================================================")
|
|
message("= zadd_executable:${ZADD_EXECUTABLE_TARGET}")
|
|
message("=================================================================")
|
|
|
|
if(ZADD_EXECUTABLE_TARGET)
|
|
message("ADD TARGET: ${ZADD_EXECUTABLE_TARGET}")
|
|
else()
|
|
message(FATAL_ERROR,"zadd_executable not set target")
|
|
endif()
|
|
|
|
message("CMAKE_C_COMPILER : ${CMAKE_C_COMPILER}")
|
|
message("CMAKE_CXX_COMPILER: ${CMAKE_CXX_COMPILER}")
|
|
|
|
if(ZADD_EXECUTABLE_INSTALL)
|
|
message("INSTALL : ${ZADD_EXECUTABLE_INSTALL}")
|
|
endif()
|
|
|
|
if(ZADD_EXECUTABLE_SRC)
|
|
# message("SRC: ${ZADD_EXECUTABLE_SRC}")
|
|
# foreach(EACH ${ZADD_EXECUTABLE_SRC})
|
|
# message(" ${EACH}")
|
|
# endforeach(EACH)
|
|
else()
|
|
message(FATAL_ERROR,"zadd_executable not set src")
|
|
endif()
|
|
|
|
add_executable(${ZADD_EXECUTABLE_TARGET} ${ZADD_EXECUTABLE_SRC})
|
|
|
|
if(ZADD_EXECUTABLE_DEFINES)
|
|
message("DEFINES:")
|
|
foreach(EACH ${ZADD_EXECUTABLE_DEFINES})
|
|
message(" ${EACH}")
|
|
endforeach(EACH)
|
|
target_compile_definitions(${ZADD_EXECUTABLE_TARGET} PRIVATE ${ZADD_EXECUTABLE_DEFINES})
|
|
endif()
|
|
|
|
|
|
if(ZADD_EXECUTABLE_DEPENDENCIES)
|
|
message("DEPENDENCIES: ")
|
|
foreach(EACH ${ZADD_EXECUTABLE_DEPENDENCIES})
|
|
message(" ${EACH}")
|
|
endforeach(EACH)
|
|
add_dependencies(${ZADD_EXECUTABLE_TARGET} ${ZADD_EXECUTABLE_DEPENDENCIES})
|
|
endif()
|
|
|
|
if(ZADD_EXECUTABLE_LINK_LIBRARIES)
|
|
message("LINK_LIBRARIES:")
|
|
foreach(EACH ${ZADD_EXECUTABLE_LINK_LIBRARIES})
|
|
message(" ${EACH}")
|
|
endforeach(EACH)
|
|
target_link_libraries(${ZADD_EXECUTABLE_TARGET} ${ZADD_EXECUTABLE_LINK_LIBRARIES})
|
|
endif()
|
|
|
|
if(ZADD_EXECUTABLE_LINK_DIRECTORIES)
|
|
message("LINK_DIRECTORIES:")
|
|
foreach(EACH ${ZADD_EXECUTABLE_LINK_DIRECTORIES})
|
|
message(" ${EACH}")
|
|
endforeach(EACH)
|
|
target_link_directories(${ZADD_EXECUTABLE_TARGET} PRIVATE ${ZADD_EXECUTABLE_LINK_DIRECTORIES})
|
|
endif()
|
|
|
|
if(ZADD_EXECUTABLE_INCLUDE_DIRECTORIES)
|
|
message("INCLUDE_DIRECTORIES:")
|
|
foreach(EACH ${ZADD_EXECUTABLE_INCLUDE_DIRECTORIES})
|
|
message(" ${EACH}")
|
|
endforeach(EACH)
|
|
target_include_directories(${ZADD_EXECUTABLE_TARGET} PRIVATE ${ZADD_EXECUTABLE_INCLUDE_DIRECTORIES})
|
|
endif()
|
|
message("")
|
|
message("")
|
|
|
|
if(ZADD_EXECUTABLE_INSTALL)
|
|
install(TARGETS ${ZADD_EXECUTABLE_TARGET} DESTINATION ${ZADD_EXECUTABLE_INSTALL})
|
|
endif()
|
|
endfunction(zadd_executable)
|