vcpkg/ports/libvhdi/CMakeLists.txt
TomKatom 2cb7bfd2ce
[libvhdi] Initial Port (#36063)
* Add libvhdi library to vcpkg

* Fixed formatting.

* version database.

* Added license.

* Fixed version formatting.

* Updated version.

* Fix osx build.

* Added version.

* Fixed config.h file.

* Added versions.

* Check for linux/fs.h

* Added version.

* Fix include.

* Added version.

* Fixed build.

* Fixed formatting.

* Added version.

* Fixed dependencies.

* Added version.

* Fixed build.

* Fixed formatting.

* Added versions.

* Revert "Added versions."

This reverts commit 94e0c97c74617c84be657807aefbedc061bf67a9.

* Revert "Fixed formatting."

This reverts commit 29a8590ee0810b447975d228509a4335f2058202.

* Revert "Fixed build."

This reverts commit 63622e6c3dc2fa31f2d28017aecdf3fcfb9f7726.

* Revert "Added version."

This reverts commit a9e0110664bc31a4fdd603cdd014957ce0a4ef90.

* Revert "Fixed dependencies."

This reverts commit c0517a5f969820c2206ccb9f09f9bafa7d45e0b4.

* Use CMake again.

* Fix MacOS build.

* updated version.

* Fixed CMake config.

* Updated version.
2024-02-09 20:03:54 -08:00

84 lines
2.9 KiB
CMake

cmake_minimum_required(VERSION 3.12)
project(libvhdi C)
find_package(ZLIB REQUIRED)
if(MSVC)
add_compile_definitions(_CRT_SECURE_NO_DEPRECATE)
add_compile_definitions(_CRT_NONSTDC_NO_DEPRECATE)
endif()
add_compile_definitions(HAVE_LOCAL_LIBCERROR)
add_compile_definitions(HAVE_LOCAL_LIBCTHREADS)
add_compile_definitions(HAVE_LOCAL_LIBCDATA)
add_compile_definitions(HAVE_LOCAL_LIBCLOCALE)
add_compile_definitions(HAVE_LOCAL_LIBCNOTIFY)
add_compile_definitions(HAVE_LOCAL_LIBCSPLIT)
add_compile_definitions(HAVE_LOCAL_LIBCFILE)
add_compile_definitions(HAVE_LOCAL_LIBCPATH)
add_compile_definitions(HAVE_LOCAL_LIBUNA)
add_compile_definitions(HAVE_LOCAL_LIBBFIO)
add_compile_definitions(HAVE_LOCAL_LIBFCACHE)
add_compile_definitions(HAVE_LOCAL_LIBFDATA)
add_compile_definitions(HAVE_LOCAL_LIBFVALUE)
add_compile_definitions(HAVE_LOCAL_LIBFGUID)
add_compile_definitions(ZLIB_DLL)
if(UNIX)
configure_file(common/config.h.in common/config.h)
add_compile_definitions(HAVE_CONFIG_H)
add_compile_definitions(LOCALEDIR="/usr/share/locale")
endif()
if(MSVC)
add_compile_definitions(LIBVHDI_DLL_EXPORT)
set(LIB_RC libvhdi/libvhdi.rc)
endif()
include(GNUInstallDirs)
include(CMakePackageConfigHelpers)
# Add CMake find_package() integration
set(PROJECT_TARGET_NAME "${PROJECT_NAME}")
set(CONFIG_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}")
set(PROJECT_CONFIG "${CMAKE_CURRENT_BINARY_DIR}/generated/${PROJECT_TARGET_NAME}Config.cmake")
set(TARGETS_EXPORT_NAME "${PROJECT_TARGET_NAME}Targets")
set(NAMESPACE "libvhdi::")
# Source files
file(GLOB LIB_SRC lib*/*.c)
# Headers
file(GLOB LIB_INST_HEADERS include/libvhdi/*.h)
add_library(${PROJECT_NAME} ${LIB_SRC} ${LIB_RC})
target_include_directories(${PROJECT_NAME} PRIVATE ./include ./common)
target_include_directories(${PROJECT_NAME} PRIVATE ./libbfio ./libcdata ./libcerror ./libcfile ./libclocale)
target_include_directories(${PROJECT_NAME} PRIVATE ./libcnotify ./libcpath ./libcsplit ./libcthreads)
target_include_directories(${PROJECT_NAME} PRIVATE ./libfcache ./libfdata ./libfvalue ./libuna ./libfguid)
target_link_libraries(${PROJECT_NAME} PRIVATE ZLIB::ZLIB)
install(TARGETS ${PROJECT_NAME}
EXPORT ${TARGETS_EXPORT_NAME}
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
INCLUDES DESTINATION include)
install(FILES ${LIB_INST_HEADERS} DESTINATION include/libvhdi)
install(FILES include/libvhdi.h DESTINATION include)
# Generate and install libvhdiConfig.cmake
configure_package_config_file("Config.cmake.in" "${PROJECT_CONFIG}" INSTALL_DESTINATION "${CONFIG_INSTALL_DIR}")
install(FILES "${PROJECT_CONFIG}" DESTINATION "${CONFIG_INSTALL_DIR}")
# Generate and install libvhdiTargets*.cmake
install(EXPORT ${TARGETS_EXPORT_NAME}
NAMESPACE ${NAMESPACE}
DESTINATION "${CONFIG_INSTALL_DIR}")