2020-02-05 03:32:03 +08:00
|
|
|
cmake_minimum_required(VERSION 3.13)
|
2019-08-17 08:22:04 +08:00
|
|
|
|
2019-10-08 01:35:13 +08:00
|
|
|
option(CMAKE_VERBOSE_MAKEFILE "Create verbose makefile" OFF)
|
|
|
|
option(BUILD_SHARED_LIBS "Create duktape as a shared library" ON)
|
|
|
|
|
2024-03-30 08:24:58 +08:00
|
|
|
project(duktape VERSION ${VERSION})
|
2017-07-15 02:37:25 +08:00
|
|
|
|
2019-10-08 01:35:13 +08:00
|
|
|
file(GLOB_RECURSE DUKTAPE_SOURCES "${CMAKE_CURRENT_LIST_DIR}/src/*.c")
|
|
|
|
file(GLOB_RECURSE DUKTAPE_HEADERS "${CMAKE_CURRENT_LIST_DIR}/src/*.h")
|
2019-05-03 13:57:43 +08:00
|
|
|
|
2017-07-15 04:36:48 +08:00
|
|
|
add_library(duktape ${DUKTAPE_SOURCES} ${DUKTAPE_HEADERS})
|
2019-10-08 01:35:13 +08:00
|
|
|
target_include_directories(duktape PRIVATE "${CMAKE_CURRENT_LIST_DIR}/src")
|
2024-03-30 08:24:58 +08:00
|
|
|
target_include_directories(duktape PUBLIC "$<INSTALL_INTERFACE:include>")
|
2019-10-08 01:35:13 +08:00
|
|
|
set_target_properties(duktape PROPERTIES PUBLIC_HEADER "${DUKTAPE_HEADERS}")
|
2020-11-26 03:25:02 +08:00
|
|
|
set_target_properties(duktape PROPERTIES VERSION ${duktape_VERSION})
|
2024-03-30 08:24:58 +08:00
|
|
|
set_target_properties(duktape PROPERTIES SOVERSION ${duktape_VERSION_MAJOR})
|
2017-07-15 02:37:25 +08:00
|
|
|
|
2019-10-08 01:35:13 +08:00
|
|
|
if (BUILD_SHARED_LIBS)
|
|
|
|
target_compile_definitions(duktape PRIVATE -DDUK_F_DLL_BUILD)
|
|
|
|
endif ()
|
2017-07-15 04:36:48 +08:00
|
|
|
|
|
|
|
install(TARGETS duktape
|
2019-10-08 01:35:13 +08:00
|
|
|
EXPORT duktapeTargets
|
2017-07-15 02:37:25 +08:00
|
|
|
ARCHIVE DESTINATION "lib"
|
2019-10-08 01:35:13 +08:00
|
|
|
LIBRARY DESTINATION "lib"
|
2017-07-15 02:37:25 +08:00
|
|
|
RUNTIME DESTINATION "bin"
|
2019-10-08 01:35:13 +08:00
|
|
|
PUBLIC_HEADER DESTINATION "include"
|
|
|
|
COMPONENT dev
|
|
|
|
)
|
|
|
|
|
|
|
|
install(EXPORT duktapeTargets
|
2024-03-30 08:24:58 +08:00
|
|
|
FILE unofficial-duktape-config.cmake
|
|
|
|
NAMESPACE unofficial::duktape::
|
|
|
|
DESTINATION "share/unofficial-duktape"
|
2019-10-08 01:35:13 +08:00
|
|
|
)
|
|
|
|
|
|
|
|
export(PACKAGE duktape)
|
|
|
|
|
|
|
|
include(CMakePackageConfigHelpers)
|
2024-03-30 08:24:58 +08:00
|
|
|
write_basic_package_version_file("${PROJECT_BINARY_DIR}/unofficial-duktape-config-version.cmake"
|
2019-10-08 01:35:13 +08:00
|
|
|
COMPATIBILITY SameMajorVersion
|
|
|
|
)
|
|
|
|
|
|
|
|
install(FILES
|
2024-03-30 08:24:58 +08:00
|
|
|
"${PROJECT_BINARY_DIR}/unofficial-duktape-config-version.cmake"
|
|
|
|
DESTINATION "share/unofficial-duktape"
|
|
|
|
)
|
|
|
|
|
|
|
|
set(prefix "")
|
|
|
|
set(LIBDIR "/lib")
|
|
|
|
set(VERSION "${duktape_VERSION}")
|
|
|
|
configure_file("${CMAKE_CURRENT_SOURCE_DIR}/duktape.pc.in" "${CMAKE_CURRENT_BINARY_DIR}/duktape.pc" @ONLY)
|
|
|
|
install(
|
|
|
|
FILES "${CMAKE_CURRENT_BINARY_DIR}/duktape.pc"
|
|
|
|
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig"
|
2019-10-08 01:35:13 +08:00
|
|
|
)
|