215 lines
7.7 KiB
CMake
215 lines
7.7 KiB
CMake
cmake_minimum_required (VERSION 3.5)
|
|
|
|
# 使MT设置生效
|
|
if (POLICY CMP0091)
|
|
cmake_policy(SET CMP0091 NEW)
|
|
endif (POLICY CMP0091)
|
|
|
|
project ("dl")
|
|
|
|
set(LIBTYPE STATIC)
|
|
message("生成目标平台:${CMAKE_SYSTEM}")
|
|
|
|
|
|
message("------------------dl option------------------")
|
|
set(DL_VULKAN_DIR AUTO)
|
|
#set(DL_VULKAN_DIR D:/VulkanSDK/1.3.268.0)
|
|
#set(DL_VULKAN_DIR D:/VulkanSDK/1.3.250.0)
|
|
message("------------------dl option------------------")
|
|
# 设为true禁用绘图
|
|
if(false)
|
|
set(DL_DISABLE_RENDER true)
|
|
set(DL_DISABLE_AUDIO true)
|
|
set(DL_DISABLE_OPENSSL false)
|
|
set(DL_DISABLE_CURL false)
|
|
set(DL_DISABLE_CONSOLE true)
|
|
set(DL_USE_MT true)
|
|
else()
|
|
set(DL_DISABLE_RENDER false)
|
|
set(DL_DISABLE_AUDIO false)
|
|
set(DL_DISABLE_OPENSSL false)
|
|
set(DL_DISABLE_CURL false)
|
|
set(DL_DISABLE_CONSOLE false) # 仅控制是否有控制台
|
|
set(DL_USE_MT false)
|
|
endif()
|
|
# 安卓暂不使用openssl
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
set(DL_DISABLE_OPENSSL true)
|
|
set(DL_DISABLE_CURL true)
|
|
endif()
|
|
|
|
if(DL_USE_MT)
|
|
set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreaded$<$<CONFIG:Debug>:Debug>")
|
|
endif()
|
|
|
|
# release生成pdb
|
|
set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /Zi")
|
|
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "${CMAKE_EXE_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
|
|
set(CMAKE_SHARED_LINKER_FLAGS_RELEASE "${CMAKE_SHARED_LINKER_FLAGS_RELEASE} /DEBUG /OPT:REF /OPT:ICF")
|
|
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /Zi")
|
|
endif()
|
|
|
|
set(CMAKE_CXX_STANDARD 23)
|
|
|
|
message("------------------第三方库option------------------")
|
|
if(DEFINED BUILD_DOCS)
|
|
unset(BUILD_DOCS CACHE)
|
|
endif()
|
|
option(BUILD_DOCS "关闭第三方库的文档生成" OFF)
|
|
|
|
if(DEFINED INSTALL_MANPAGES)
|
|
unset(INSTALL_MANPAGES CACHE)
|
|
endif()
|
|
option(INSTALL_MANPAGES "解决flac报错" OFF)
|
|
|
|
if(DEFINED ALSOFT_INSTALL)
|
|
unset(ALSOFT_INSTALL CACHE)
|
|
endif()
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
option(ALSOFT_INSTALL "解决安卓openal报错" OFF)
|
|
endif()
|
|
|
|
if(DEFINED CURL_USE_OPENSSL)
|
|
unset(CURL_USE_OPENSSL CACHE)
|
|
endif()
|
|
option(CURL_USE_OPENSSL "curl启用openssl(暂不支持)" OFF)
|
|
|
|
if(DEFINED FT_DISABLE_ZLIB)
|
|
unset(FT_DISABLE_ZLIB CACHE)
|
|
endif()
|
|
option(FT_DISABLE_ZLIB "freetype禁用内部zlib" ON)
|
|
|
|
if(DEFINED FT_REQUIRE_ZLIB)
|
|
unset(FT_REQUIRE_ZLIB CACHE)
|
|
endif()
|
|
option(FT_REQUIRE_ZLIB "freetype查找外部zlib" ON)
|
|
|
|
|
|
include_directories(${CMAKE_SOURCE_DIR}/third/other)
|
|
message("------------------解析第三方库------------------")
|
|
message("------------------lz4 压缩库-------------------")
|
|
add_subdirectory ("third/lz4")
|
|
message("------------------zlib 压缩库---------")
|
|
add_subdirectory ("third/zlib")
|
|
message("------------------fmt 文本格式化库--------------")
|
|
add_subdirectory ("third/fmt")
|
|
|
|
message("------------------lunasvg svg格式库-----------")
|
|
add_subdirectory ("third/lunasvg")
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
message("------------------libwebp webp格式库-----------")
|
|
add_subdirectory ("third/libwebp")
|
|
endif()
|
|
message("------------------OpenXLSX xlsx格式库-----------")
|
|
add_subdirectory ("third/OpenXLSX")
|
|
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
message("------------------glfw 窗口库------------------")
|
|
add_subdirectory ("third/glfw")
|
|
endif()
|
|
message("------------------freetype 字体解析库-----------")
|
|
add_subdirectory ("third/freetype")
|
|
message("------------------ogg vorbis 音频格式库-----------")
|
|
add_subdirectory ("third/ogg")
|
|
set (OGG_LIBRARY "third/ogg")
|
|
set (OGG_INCLUDE_DIR "third/ogg")
|
|
add_subdirectory ("third/vorbis")
|
|
message("------------------flac 音频格式库-----------")
|
|
add_subdirectory ("third/flac")
|
|
message("------------------openal-soft 音频库-----------")
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Linux")
|
|
add_subdirectory ("third/openal-soft")
|
|
endif()
|
|
message("------------------rtmidi midi库-----------")
|
|
if (CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
add_subdirectory ("third/rtmidi")
|
|
endif()
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
message("------------------ode 物理引擎库-----------")
|
|
add_subdirectory ("third/ode")
|
|
endif()
|
|
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Windows")
|
|
message("------------------iconv 文本编码转换库-----------")
|
|
#add_subdirectory ("third/libiconv")
|
|
endif()
|
|
message("------------------angelscript 脚本语言库-----------")
|
|
add_subdirectory ("third/angelscript/angelscript/projects/cmake")
|
|
message("------------------lua 脚本语言库-----------")
|
|
add_subdirectory ("third/lua")
|
|
add_subdirectory ("third/LuaBridge3")
|
|
message("------------------infoware 硬件信息库-----------")
|
|
if (NOT CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
set(INFOWARE_PCI_IDS_PATH ${CMAKE_SOURCE_DIR}/third/infoware/pci.ids CACHE FILEPATH "使用本地piiids" FORCE)
|
|
add_subdirectory ("third/infoware")
|
|
endif()
|
|
message("------------------wcwidth 字符宽度检测-----------")
|
|
add_subdirectory ("third/wcwidth")
|
|
message("------------------simde 向量化计算-----------")
|
|
add_subdirectory ("third/simde")
|
|
|
|
message("------------------其余库以其他形式链接----------")
|
|
message("------------------nlohmann-json json库---------")
|
|
message("------------------stb_image 图像解析库----------")
|
|
message("------------------qrcodegen 二维码生成库-----------")
|
|
message("------------------vld 内存泄漏检测库----------")
|
|
message("------------------asio 网络库-----------")
|
|
message("------------------tinyxml2 xml格式库-----------")
|
|
message("------------------openssl 库-----------")
|
|
message("------------------curl 库-----------")
|
|
message("------------------sqlite 数据库-----------")
|
|
message("------------------tinyobjloader obj格式库-----------")
|
|
message("------------------tinygltf gltf格式库-----------")
|
|
message("------------------mp3 音频格式库-----------")
|
|
|
|
message("------------------解析dl-----------------------")
|
|
add_subdirectory ("dl")
|
|
if(NOT DL_DISABLE_RENDER)
|
|
message("------------------解析dl_test-----------------------")
|
|
add_subdirectory ("project/dl_test")
|
|
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_editor/CMakeLists.txt)
|
|
message("------------------解析dl_editor-----------------------")
|
|
add_subdirectory ("project/dl_editor")
|
|
endif()
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_midi/CMakeLists.txt)
|
|
message("------------------解析dl_midi-----------------------")
|
|
add_subdirectory ("project/dl_midi")
|
|
endif()
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_chess/CMakeLists.txt)
|
|
message("------------------解析dl_chess-----------------------")
|
|
add_subdirectory ("project/dl_chess")
|
|
endif()
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_snake/CMakeLists.txt)
|
|
message("------------------解析dl_snake-----------------------")
|
|
add_subdirectory ("project/dl_snake")
|
|
endif()
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/project/hs/CMakeLists.txt)
|
|
message("------------------解析HistorySim-----------------------")
|
|
add_subdirectory ("project/hs")
|
|
endif()
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/project/ds/CMakeLists.txt)
|
|
message("------------------解析DreamSandbox-----------------------")
|
|
add_subdirectory ("project/ds")
|
|
endif()
|
|
endif()
|
|
|
|
if(NOT CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
message("------------------解析dl_console-----------------------")
|
|
add_subdirectory ("project/dl_console")
|
|
endif()
|
|
|
|
if(EXISTS ${CMAKE_SOURCE_DIR}/project/dl_config/CMakeLists.txt AND
|
|
NOT CMAKE_SYSTEM_NAME MATCHES "Android")
|
|
message("------------------解析dl_config-----------------------")
|
|
add_subdirectory ("project/dl_config")
|
|
endif()
|
|
|
|
|
|
|
|
message("若解析Cmake失败,有以下几个常见原因:")
|
|
message("1.未安装VulkanSDK")
|
|
message("2.需要以管理员权限运行ide(执行批处理以进行资源软连接)")
|
|
message("CMake生成完成后,请选择dl_test项目调试") |