2021-12-31 04:45:32 +00:00
|
|
|
cmake_minimum_required(VERSION 3.9)
|
|
|
|
cmake_policy(SET CMP0042 NEW)
|
2022-01-21 04:52:29 +00:00
|
|
|
project(image)
|
2021-12-31 04:45:32 +00:00
|
|
|
include_directories(${CMAKE_JS_INC})
|
|
|
|
file(GLOB SOURCE_FILES "natives/*.cc" "natives/*.h")
|
|
|
|
add_library(${PROJECT_NAME} SHARED ${SOURCE_FILES} ${CMAKE_JS_SRC})
|
|
|
|
set_target_properties(${PROJECT_NAME} PROPERTIES PREFIX "" SUFFIX ".node")
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${CMAKE_JS_LIB})
|
2022-01-01 02:55:53 +00:00
|
|
|
target_compile_features(${PROJECT_NAME} PRIVATE cxx_std_17)
|
2022-01-26 18:01:31 +00:00
|
|
|
if(MSVC) # todo: change flags for more parity with GCC/clang, I don't know much about MSVC so pull requests are open
|
|
|
|
set(CMAKE_CXX_FLAGS "/Wall /EHsc /GS")
|
2022-01-21 06:52:15 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "/Zi")
|
2022-01-26 18:01:31 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "/Ox")
|
|
|
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
|
|
|
|
set(BUILD_SHARED_LIBS TRUE)
|
2022-01-21 06:52:15 +00:00
|
|
|
else()
|
|
|
|
set(CMAKE_CXX_FLAGS "-Wall -Wextra -Werror=format-security -Wno-cast-function-type -fexceptions -D_GLIBCXX_ASSERTIONS -fstack-clash-protection -pedantic -D_GLIBCXX_USE_CXX11_ABI=1")
|
2022-01-21 04:52:29 +00:00
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-g")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
|
2022-01-26 18:01:31 +00:00
|
|
|
endif()
|
2022-01-21 04:52:29 +00:00
|
|
|
add_definitions(-DNAPI_VERSION=5)
|
2021-12-31 04:45:32 +00:00
|
|
|
|
|
|
|
execute_process(COMMAND node -p "require('node-addon-api').include"
|
2022-01-21 04:52:29 +00:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
|
|
OUTPUT_VARIABLE NODE_ADDON_API_DIR
|
|
|
|
)
|
2021-12-31 04:45:32 +00:00
|
|
|
string(REPLACE "\n" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
|
|
|
|
string(REPLACE "\"" "" NODE_ADDON_API_DIR ${NODE_ADDON_API_DIR})
|
|
|
|
target_include_directories(${PROJECT_NAME} PRIVATE ${NODE_ADDON_API_DIR})
|
|
|
|
|
2022-01-26 18:01:31 +00:00
|
|
|
find_package(ImageMagick COMPONENTS Magick++ MagickCore)
|
2021-12-31 04:45:32 +00:00
|
|
|
add_definitions(-DMAGICKCORE_QUANTUM_DEPTH=16)
|
|
|
|
add_definitions(-DMAGICKCORE_HDRI_ENABLE=0)
|
|
|
|
include_directories(${ImageMagick_INCLUDE_DIRS})
|
|
|
|
target_link_libraries(${PROJECT_NAME} ${ImageMagick_LIBRARIES})
|