97 lines
2.7 KiB
CMake
97 lines
2.7 KiB
CMake
cmake_minimum_required(VERSION 3.10.0)
|
|
project(ai-box VERSION 0.1.0 LANGUAGES C CXX)
|
|
set(CMAKE_CXX_STANDARD 17)
|
|
|
|
if (POLICY CMP0091)
|
|
cmake_policy(SET CMP0091 NEW)
|
|
endif (POLICY CMP0091)
|
|
|
|
if(NOT DEFINED CMAKE_BUILD_TYPE)
|
|
set(CMAKE_BUILD_TYPE Release)
|
|
endif()
|
|
|
|
set(NODE_ADDON_FOUND OFF)
|
|
|
|
include_directories(cxx)
|
|
|
|
# FFmpeg
|
|
set(FFMPEG_CMAKE_FILE ${CMAKE_SOURCE_DIR}/thirdpart/FFmpeg/config.cmake)
|
|
if(EXISTS ${FFMPEG_CMAKE_FILE})
|
|
include(${FFMPEG_CMAKE_FILE})
|
|
message(STATUS "FFMPEG_LIB_DIR: ${FFMPEG_LIB_DIR}")
|
|
message(STATUS "FFMPEG_INCLUDE_DIR: ${FFMPEG_INCLUDE_DIR}")
|
|
message(STATUS "FFMPEG_LIBS: ${FFMPEG_LIBS}")
|
|
include_directories(${FFMPEG_INCLUDE_DIR})
|
|
link_directories(${FFMPEG_LIB_DIR})
|
|
else()
|
|
message(FATAL_ERROR "FFmpeg not found")
|
|
endif()
|
|
|
|
# NodeJS
|
|
execute_process(
|
|
COMMAND node ${CMAKE_SOURCE_DIR}/thirdpart/cmake-js-util.js --include
|
|
RESULT_VARIABLE CMAKE_JS_RESULT
|
|
OUTPUT_VARIABLE CMAKE_JS_INC
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
if(CMAKE_JS_RESULT EQUAL 0)
|
|
execute_process(
|
|
COMMAND node ${CMAKE_SOURCE_DIR}/thirdpart/cmake-js-util.js --src
|
|
RESULT_VARIABLE CMAKE_JS_RESULT
|
|
OUTPUT_VARIABLE CMAKE_JS_SRC
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
if(CMAKE_JS_RESULT EQUAL 0)
|
|
execute_process(
|
|
COMMAND node ${CMAKE_SOURCE_DIR}/thirdpart/cmake-js-util.js --lib
|
|
RESULT_VARIABLE CMAKE_JS_RESULT
|
|
OUTPUT_VARIABLE CMAKE_JS_LIB
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
endif()
|
|
# ReleaseVersion
|
|
if(CMAKE_JS_RESULT EQUAL 0)
|
|
execute_process(
|
|
COMMAND node ${CMAKE_SOURCE_DIR}/thirdpart/cmake-js-util.js --release
|
|
RESULT_VARIABLE CMAKE_JS_RESULT
|
|
OUTPUT_VARIABLE RELEASE_VERSION
|
|
OUTPUT_STRIP_TRAILING_WHITESPACE
|
|
)
|
|
if(CMAKE_JS_RESULT EQUAL 0)
|
|
message(STATUS "RELEASE_VERSION: ${RELEASE_VERSION}")
|
|
add_compile_definitions(RELEASE_VERSION="${RELEASE_VERSION}")
|
|
endif()
|
|
endif()
|
|
|
|
# NAPI
|
|
if(CMAKE_JS_RESULT EQUAL 0)
|
|
execute_process(
|
|
COMMAND node ${CMAKE_SOURCE_DIR}/thirdpart/cmake-js-util.js --napi
|
|
RESULT_VARIABLE CMAKE_JS_RESULT
|
|
OUTPUT_VARIABLE NODE_ADDON_API_DIR
|
|
)
|
|
endif()
|
|
if(CMAKE_JS_RESULT EQUAL 0)
|
|
message(STATUS "CMAKE_JS_INC: ${CMAKE_JS_INC}")
|
|
message(STATUS "CMAKE_JS_SRC: ${CMAKE_JS_SRC}")
|
|
message(STATUS "CMAKE_JS_LIB: ${CMAKE_JS_LIB}")
|
|
message(STATUS "NODE_ADDON_API_DIR: ${NODE_ADDON_API_DIR}")
|
|
include_directories(${CMAKE_JS_INC} ${NODE_ADDON_API_DIR})
|
|
set(NODE_ADDON_FOUND ON)
|
|
endif()
|
|
endif()
|
|
if(NOT (CMAKE_JS_RESULT EQUAL 0))
|
|
message(FATAL_ERROR "cmake js config failed")
|
|
endif()
|
|
|
|
|
|
# 平台特定的库
|
|
if(MSVC)
|
|
set(PLATFORM_LIBS ws2_32 winmm strmiids mfplat mfuuid Ws2_32 Secur32 Bcrypt)
|
|
endif()
|
|
|
|
include_directories(thirdpart/FFmpeg/include)
|
|
link_directories(thirdpart/FFmpeg/lib)
|
|
add_executable(ffmpeg cxx/main.cc)
|
|
target_link_libraries(ffmpeg ${PLATFORM_LIBS} ${FFMPEG_LIBS})
|