cmake_minimum_required(VERSION 3.21) project(render) set(CMAKE_CXX_STANDARD 26 REQUIRED) if (MSVC) add_compile_options(/utf-8) else () add_compile_options(-finput-charset=UTF-8) add_compile_options(-fexec-charset=UTF-8) endif () add_compile_definitions( WIN32_LEAN_AND_MEAN NOMINMAX UNICODE _UNICODE ) string(ASCII 27 Esc) set(Y "${Esc}[1:33m") # 黄色字体 set(E "${Esc}[0m") if (NOT EXISTS "${CMAKE_SOURCE_DIR}/CMakeLocalPath.cmake") file(COPY "cmake/CMakeLocalPath.cmake.template" DESTINATION ${CMAKE_SOURCE_DIR}) file(RENAME "${CMAKE_SOURCE_DIR}/CMakeLocalPath.cmake.template" "${CMAKE_SOURCE_DIR}/CMakeLocalPath.cmake") message(FATAL_ERROR "Please Config the CMakeLocalPath.cmake File") endif () #### 在同级目录下的CMakeLocalPath.cmake文件中设定库文件路径 #### include(${CMAKE_SOURCE_DIR}/CMakeLocalPath.cmake) # include(${CMAKE_SOURCE_DIR}/cmake/find_vcpkg.cmake OPTIONAL) include(${CMAKE_SOURCE_DIR}/cmake/find_opencv.cmake OPTIONAL) include(${CMAKE_SOURCE_DIR}/cmake/find_qt.cmake OPTIONAL) message("${Y}==== find库文件检索完毕 ====") message("==== add 3rd modules ====") set(TG_IMPORTED imported) add_subdirectory(3rd) #list(APPEND CMAKE_PREFIX_PATH ${CMAKE_SOURCE_DIR}/3rd/assimp/Debug) message("此时的CMAKE_PREFIX_PATH:${CMAKE_PREFIX_PATH} ${E}") #### 拷贝依赖函数 #### # 某个target到最后调用这个函数即可 # 如: # COPY_DEPS_TO_EXE_DIR(${TG_CONSOLE}) function(COPY_DEPS_TO_EXE_DIR TGT) set(DEP_DIRS "") foreach (item IN LISTS CMAKE_PREFIX_PATH) list(APPEND DEP_DIRS "${item}/bin") endforeach () string(JOIN "__CMAKE_LIST_SEP__" DEP_DIRS_PIPE ${DEP_DIRS}) add_custom_command(TARGET ${TGT} POST_BUILD COMMAND ${CMAKE_COMMAND} -DINPUT=$ -DDIRS=${DEP_DIRS_PIPE} -P "${CMAKE_SOURCE_DIR}/cmake/copy_deps_to_exe_dir.cmake" VERBATIM ) endfunction() set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/out) file(GLOB_RECURSE TEMPLATE_FILES CONFIGURE_DEPENDS ${CMAKE_SOURCE_DIR}/template/*) set(TEMPLATE_DIR_INCLUDE ${CMAKE_SOURCE_DIR}/template/include) #### TARGETS #### set(TG_CORE core) set(TG_TOOL tool) set(TG_ZCV zcv) set(TG_ZASSIMP zassimp) set(TG_RENDER render) set(TG_CONSOLE console) set(TG_APP app) add_subdirectory(core) add_subdirectory(tool) if (${USE_OPENCV}) add_subdirectory(zcv) endif () add_subdirectory(zassimp) add_subdirectory(render) add_subdirectory(console) add_subdirectory(app)