11cmake_minimum_required (VERSION 3.24.0.0)
2- project (sqlite3mc)
2+ project (sqlite3mc VERSION 2.1.1 )
33
44# Helper macro
55macro (_Enable_MT _target)
@@ -300,10 +300,19 @@ else()
300300endif ()
301301
302302# Lib Project
303- add_library (${SQLITE3MC_TARGET} ${SQLITE3MC_LINK}
304- ${SQLITE3MC_BASE_SRCS}
303+ add_library (${SQLITE3MC_TARGET} ${SQLITE3MC_LINK} )
304+ add_library (${PROJECT_NAME} ::${SQLITE3MC_TARGET} ALIAS ${SQLITE3MC_TARGET} )
305+
306+ target_sources (${SQLITE3MC_TARGET}
307+ PRIVATE
308+ ${SQLITE3MC_BASE_SRCS}
309+
310+ PUBLIC
311+ FILE_SET HEADERS
312+ BASE_DIRS src
313+ FILES ${SQLITE3MC_PUBLIC_HEADERS}
305314)
306- target_include_directories (${SQLITE3MC_TARGET} PUBLIC
315+ target_include_directories (${SQLITE3MC_TARGET} PRIVATE
307316 ${SQLITE3MC_INCLUDEDIRS}
308317)
309318target_compile_definitions (${SQLITE3MC_TARGET} PRIVATE
@@ -337,7 +346,7 @@ if(SQLITE3MC_WITH_ICU)
337346 target_compile_definitions (${SQLITE3MC_TARGET} PRIVATE
338347 ${SQLITE3MC_ICU_DEFINITIONS}
339348 )
340- target_include_directories (${SQLITE3MC_TARGET} PRIVATE
349+ target_include_directories (${SQLITE3MC_TARGET} PRIVATE
341350 ${ICU_INCLUDE_DIRS}
342351 )
343352 target_link_libraries (${SQLITE3MC_TARGET} PRIVATE
@@ -352,12 +361,35 @@ if(SQLITE3MC_STATIC_RUNTIME_LINK)
352361endif ()
353362message ("Will build ${SQLITE3MC_TARGET} as ${SQLITE3MC_LINK} " )
354363
355- set_target_properties ( ${SQLITE3MC_TARGET} PROPERTIES PUBLIC_HEADER " ${SQLITE3MC_PUBLIC_HEADERS} " )
364+ include (GNUInstallDirs )
356365INSTALL (TARGETS ${SQLITE3MC_TARGET}
357- ARCHIVE DESTINATION lib
358- LIBRARY DESTINATION lib
359- PUBLIC_HEADER DESTINATION include /${PROJECT_NAME}
360- RUNTIME DESTINATION bin
366+ EXPORT ${SQLITE3MC_TARGET} Targets
367+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
368+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
369+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
370+ FILE_SET HEADERS DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} /${PROJECT_NAME}
371+ COMPONENT libraries
372+ )
373+
374+ install (EXPORT ${SQLITE3MC_TARGET} Targets DESTINATION ${CMAKE_INSTALL_LIBDIR} /cmake/${SQLITE3MC_TARGET} )
375+
376+ # Create config for find_package()
377+ include (CMakePackageConfigHelpers)
378+ write_basic_package_version_file(${CMAKE_CURRENT_BINARY_DIR} /${SQLITE3MC_TARGET} ConfigVersion.cmake COMPATIBILITY SameMajorVersion)
379+ set (SQLITE3MC_CONFIG_CONTENT "@PACKAGE_INIT@\n " )
380+ string (APPEND SQLITE3MC_CONFIG_CONTENT "include(\"\$ {CMAKE_CURRENT_LIST_DIR}/${SQLITE3MC_TARGET} Targets.cmake\" )" )
381+ file (WRITE ${CMAKE_CURRENT_BINARY_DIR} /${SQLITE3MC_TARGET} Config.cmake.in ${SQLITE3MC_CONFIG_CONTENT} )
382+
383+ configure_package_config_file(
384+ ${CMAKE_CURRENT_BINARY_DIR} /${SQLITE3MC_TARGET} Config.cmake.in
385+ ${SQLITE3MC_TARGET} Config.cmake
386+ INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${SQLITE3MC_TARGET} "
387+ )
388+
389+ install (FILES
390+ ${CMAKE_CURRENT_BINARY_DIR} /${SQLITE3MC_TARGET} ConfigVersion.cmake
391+ ${CMAKE_CURRENT_BINARY_DIR} /${SQLITE3MC_TARGET} Config.cmake
392+ DESTINATION "${CMAKE_INSTALL_LIBDIR} /cmake/${SQLITE3MC_TARGET} "
361393)
362394
363395# Shell Executable project
@@ -390,7 +422,7 @@ if(SQLITE3MC_BUILD_SHELL)
390422 target_compile_definitions (${SQLITE3MC_SHELL_TARGET} PRIVATE
391423 ${SQLITE3MC_ICU_DEFINITIONS}
392424 )
393- target_include_directories (${SQLITE3MC_SHELL_TARGET} PRIVATE
425+ target_include_directories (${SQLITE3MC_SHELL_TARGET} PRIVATE
394426 ${ICU_INCLUDE_DIRS}
395427 )
396428 target_link_libraries (${SQLITE3MC_SHELL_TARGET} PRIVATE
@@ -401,14 +433,13 @@ if(SQLITE3MC_BUILD_SHELL)
401433
402434 if (SQLITE3MC_RUNTIME_LINK)
403435 message ("Will build ${SQLITE3MC_SHELL_TARGET} with static runtime" )
404- _Enable_MT(${SQLIT3MC_SHELL_TARGET } )
436+ _Enable_MT(${SQLITE3MC_SHELL_TARGET } )
405437 endif ()
406438 message ("Will build ${SQLITE3MC_SHELL_TARGET} " )
407439
408440 INSTALL (TARGETS ${SQLITE3MC_SHELL_TARGET}
409- ARCHIVE DESTINATION lib
410- LIBRARY DESTINATION lib
411- PUBLIC_HEADER DESTINATION include /${PROJECT_NAME}
412- RUNTIME DESTINATION bin
441+ ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
442+ LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
443+ RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR}
413444 )
414445endif ()
0 commit comments