### Set target properties and installation rules Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Configures symbol visibility and defines installation paths for the library and header files. ```cmake set_target_properties(DjInterop PROPERTIES C_VISIBILITY_PRESET hidden) set_target_properties(DjInterop PROPERTIES CXX_VISIBILITY_PRESET hidden) install(TARGETS DjInterop EXPORT DjInteropTargets ARCHIVE DESTINATION "${CMAKE_INSTALL_LIBDIR}" LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" RUNTIME DESTINATION "${CMAKE_INSTALL_BINDIR}") install(FILES ${CMAKE_CURRENT_BINARY_DIR}/include/djinterop/config.hpp include/djinterop/album_art.hpp include/djinterop/crate.hpp include/djinterop/database.hpp include/djinterop/djinterop.hpp include/djinterop/exceptions.hpp include/djinterop/musical_key.hpp include/djinterop/pad_color.hpp include/djinterop/performance_data.hpp include/djinterop/playlist.hpp include/djinterop/semantic_version.hpp include/djinterop/stream_helper.hpp include/djinterop/track.hpp include/djinterop/track_snapshot.hpp DESTINATION "${DJINTEROP_INSTALL_INCLUDEDIR}") install(FILES include/djinterop/engine/base_engine_library.hpp include/djinterop/engine/engine.hpp include/djinterop/engine/engine_schema.hpp DESTINATION "${DJINTEROP_INSTALL_INCLUDEDIR}/engine") install(FILES include/djinterop/engine/v2/beat_data_blob.hpp include/djinterop/engine/v2/change_log_table.hpp include/djinterop/engine/v2/engine_library.hpp include/djinterop/engine/v2/information_table.hpp include/djinterop/engine/v2/loops_blob.hpp include/djinterop/engine/v2/overview_waveform_data_blob.hpp include/djinterop/engine/v2/playlist_entity_table.hpp include/djinterop/engine/v2/playlist_table.hpp include/djinterop/engine/v2/quick_cues_blob.hpp include/djinterop/engine/v2/track_data_blob.hpp include/djinterop/engine/v2/track_table.hpp DESTINATION "${DJINTEROP_INSTALL_INCLUDEDIR}/engine/v2") install(FILES include/djinterop/engine/v3/beat_data_blob.hpp include/djinterop/engine/v3/engine_library.hpp include/djinterop/engine/v3/information_table.hpp include/djinterop/engine/v3/loops_blob.hpp include/djinterop/engine/v3/overview_waveform_data_blob.hpp include/djinterop/engine/v3/playlist_entity_table.hpp include/djinterop/engine/v3/playlist_table.hpp include/djinterop/engine/v3/quick_cues_blob.hpp include/djinterop/engine/v3/track_data_blob.hpp include/djinterop/engine/v3/track_table.hpp DESTINATION "${DJINTEROP_INSTALL_INCLUDEDIR}/engine/v3") ``` -------------------------------- ### Define Example Program Builder Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Defines a function to simplify the creation of example executables and links them against the main library. ```cmake option(BUILD_EXAMPLES "Build example programs" ON) if (BUILD_EXAMPLES) # Example programs demonstrating usage. function(add_djinterop_example example_name) add_executable(example_${example_name} example/${example_name}.cpp) target_include_directories(example_${example_name} PUBLIC ${CMAKE_CURRENT_BINARY_DIR}/include include) target_link_libraries(example_${example_name} PUBLIC DjInterop) endfunction() add_djinterop_example(engine_prime) add_djinterop_example(engine_library_v2_low_level) endif() ``` -------------------------------- ### Generate and install pkg-config file Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Generates a .pc file for Unix systems to facilitate library discovery. ```cmake if (UNIX) set(PKGCONFIG_TARGET djinterop) if (SYSTEM_SQLITE) set(PKGCONFIG_REQUIRES "zlib >= ${ZLIB_MIN_VERSION}, sqlite3 >= ${SQLITE_MIN_VERSION}") else() set(PKGCONFIG_REQUIRES "zlib >= ${ZLIB_MIN_VERSION}") endif() configure_file(djinterop.pc.in djinterop.pc @ONLY) install(FILES ${CMAKE_CURRENT_BINARY_DIR}/djinterop.pc DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig") endif() ``` -------------------------------- ### Configure CPack Installation Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Includes system library requirements and CPack configuration for packaging the project. ```cmake include(InstallRequiredSystemLibraries) set(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE") include(CPack) ``` -------------------------------- ### Compile engine_prime.cpp with g++ Source: https://github.com/xsco/libdjinterop/blob/main/example/README.md Use this command to compile the engine_prime example application in isolation using pkg-config to manage library dependencies. ```shell g++ -std=c++17 `pkg-config --cflags djinterop` engine_prime.cpp `pkg-config --libs djinterop` ``` -------------------------------- ### Configure ZLIB dependency Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Ensures the system installation of zlib is used for the DjInterop target. ```cmake set(ZLIB_MIN_VERSION 1.2.8) find_package(ZLIB ${ZLIB_MIN_VERSION} REQUIRED) target_include_directories( DjInterop PRIVATE SYSTEM ${ZLIB_INCLUDE_DIRS}) target_link_libraries( DjInterop PUBLIC ${ZLIB_LIBRARIES}) ``` -------------------------------- ### Configure header files and include directories Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Generates the config.hpp file from a template and configures public include directories for build and install interfaces. ```cmake # Generate config.hpp based on build-time environment. configure_file( include/djinterop/config.hpp.in include/djinterop/config.hpp) include(GNUInstallDirs) set(DJINTEROP_INSTALL_INCLUDEDIR "${CMAKE_INSTALL_INCLUDEDIR}/djinterop") target_include_directories( DjInterop PUBLIC $ $ $) ``` -------------------------------- ### Export CMake Package Configuration Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Configures and installs CMake package files to allow other projects to find and use the library. ```cmake include(CMakePackageConfigHelpers) set(DJINTEROP_INSTALL_CMAKEDIR "lib/cmake/DjInterop") install(EXPORT DjInteropTargets FILE DjInteropTargets.cmake NAMESPACE DjInterop:: DESTINATION "${DJINTEROP_INSTALL_CMAKEDIR}") configure_package_config_file( DjInteropConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/DjInteropConfig.cmake" INSTALL_DESTINATION "${DJINTEROP_INSTALL_CMAKEDIR}") write_basic_package_version_file( "${CMAKE_CURRENT_BINARY_DIR}/DjInteropConfigVersion.cmake" VERSION "${CMAKE_PROJECT_VERSION}" COMPATIBILITY SameMajorVersion) install(FILES "${CMAKE_CURRENT_BINARY_DIR}/DjInteropConfig.cmake" "${CMAKE_CURRENT_BINARY_DIR}/DjInteropConfigVersion.cmake" DESTINATION "${DJINTEROP_INSTALL_CMAKEDIR}") ``` -------------------------------- ### Enter Nix development environment Source: https://github.com/xsco/libdjinterop/blob/main/README.md Command to initialize a shell with all necessary build dependencies provided by Nix. ```shell $ nix-shell ``` -------------------------------- ### Build libdjinterop with CMake Source: https://github.com/xsco/libdjinterop/blob/main/README.md Standard sequence of commands to configure, build, and test the library using CMake. ```shell $ mkdir cmake-build $ cd cmake-build $ cmake .. $ cmake --build . $ ctest # To run unit tests ``` -------------------------------- ### Project Initialization and Policy Settings Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Sets the minimum CMake version, project metadata, and enables specific CMake policies for compatibility. ```cmake cmake_minimum_required(VERSION 3.10) project(libdjinterop VERSION 0.27.3 DESCRIPTION "C++ library providing access to DJ record libraries") set(PROJECT_HOMEPAGE_URL "https://github.com/xsco/libdjinterop") if(POLICY CMP0074) # CMP0074: find_package() uses _ROOT variables. cmake_policy(SET CMP0074 NEW) endif() if(POLICY CMP0076) # CMP0076: target_sources() command converts relative paths to absolute. cmake_policy(SET CMP0076 NEW) endif() if(POLICY CMP0167) # CMP0167: Don't use FindBoost() any longer. cmake_policy(SET CMP0167 NEW) endif() ``` -------------------------------- ### Configure Dependency Options Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Defines build options to toggle between bundled dependencies and system-installed versions. ```cmake option(SYSTEM_DATE_H "Use system installation of date.h" OFF) option(SYSTEM_SQLITE "Use system installation of SQLite" ON) option(SYSTEM_SQLITE_MODERN_CPP "Use system installation of sqlite_modern_cpp" OFF) ``` -------------------------------- ### Configure Unit Tests with Boost Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Sets up CTest and defines a helper function to compile and register unit tests that depend on the Boost library. ```cmake include(CTest) find_package(Boost 1.71.0 QUIET COMPONENTS filesystem system) if (Boost_FOUND) set(TESTDATA_DIR "${CMAKE_CURRENT_SOURCE_DIR}/testdata") function(add_djinterop_test test_dir test_name) string(REPLACE "/" "_" test_executable_name ${test_dir}${test_name}) add_executable(${test_executable_name} test/djinterop/${test_dir}${test_name}.cpp) target_compile_definitions(${test_executable_name} PUBLIC -DTESTDATA_DIR=${TESTDATA_DIR}) if (MSVC) # Some unit tests are rather large and exceed max sections on VC++. target_compile_options(${test_executable_name} PRIVATE /bigobj) endif() target_include_directories(${test_executable_name} PUBLIC ${Boost_INCLUDE_DIRS} ${CMAKE_CURRENT_BINARY_DIR}/include include) target_link_libraries(${test_executable_name} PUBLIC DjInterop ${Boost_LIBRARIES}) add_test(NAME ${test_executable_name} COMMAND ${test_executable_name}) endfunction() add_djinterop_test("" semantic_version_test) add_djinterop_test(engine/ crate_test) add_djinterop_test(engine/ database_reference_test) add_djinterop_test(engine/ database_test) add_djinterop_test(engine/ engine_test) add_djinterop_test(engine/ playlist_test) add_djinterop_test(engine/ track_test) add_djinterop_test(engine/v2/ playlist_entity_table_test) add_djinterop_test(engine/v2/ playlist_table_test) add_djinterop_test(engine/v2/ track_table_test) add_djinterop_test(engine/v3/ performance_data_table_test) add_djinterop_test(engine/v3/ track_table_test) else() message(STATUS "Unit tests not available, as Boost cannot be found") endif() ``` -------------------------------- ### Configure date.h dependency Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Toggles between using a system-installed date library or a bundled header-only version. ```cmake if(SYSTEM_DATE_H) # Search for system installation of date.h and use that. find_package(date CONFIG REQUIRED) target_link_libraries( DjInterop PUBLIC date::date) else() # Use bundled date.h (a header-only library). message(STATUS "Using bundled date.h...") target_include_directories( DjInterop PRIVATE SYSTEM ext/date) endif() ``` -------------------------------- ### Build Options Configuration Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Defines build options such as enabling shared library generation by default. ```cmake # Build shared a library by default. option(BUILD_SHARED_LIBS "Build shared library" ON) ``` -------------------------------- ### Configure Doxygen in CMake Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Defines an option to toggle documentation builds and integrates Doxygen if found on the system. ```cmake option(BUILD_DOC "Build documentation" ON) # Check if Doxygen is installed find_package(Doxygen OPTIONAL_COMPONENTS dot dia) if (DOXYGEN_FOUND) set(DOXYGEN_HTML_OUTPUT docs) set(DOXYGEN_USE_MDFILE_AS_MAINPAGE README.md) message("Doxygen build started") doxygen_add_docs( docs include README.md COMMENT "Generate docs" ) else (DOXYGEN_FOUND) message("Doxygen need to be installed to generate the doxygen documentation") endif (DOXYGEN_FOUND) ``` -------------------------------- ### Configure SQLite dependency Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Selects between a system-installed SQLite library or bundled amalgamation sources. ```cmake if(SYSTEM_SQLITE) # Search for system installation of SQLite and use that. set(SQLITE_MIN_VERSION 3.11) find_package(SQLite3 ${SQLITE_MIN_VERSION} REQUIRED) target_include_directories( DjInterop PRIVATE SYSTEM ${SQLite3_INCLUDE_DIRS}) target_link_libraries( DjInterop PUBLIC ${SQLite3_LIBRARIES}) else() # Use bundled SQLite amalgamation sources. message(STATUS "Using bundled SQLite...") target_sources( DjInterop PRIVATE ext/sqlite-amalgamation/sqlite3.c) target_compile_definitions( DjInterop PUBLIC SQLITE_OMIT_LOAD_EXTENSION) target_include_directories( DjInterop PRIVATE SYSTEM ext/sqlite-amalgamation) endif() ``` -------------------------------- ### Configure DjInterop Target Properties Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Sets the output name, version, and SOVERSION for the DjInterop library target. ```cmake set_target_properties(DjInterop PROPERTIES OUTPUT_NAME "djinterop" VERSION ${PROJECT_VERSION} SOVERSION ${PROJECT_VERSION_MAJOR}) ``` -------------------------------- ### Configure sqlite-modern-cpp dependency Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Configures the project to use either a system-installed or bundled version of sqlite-modern-cpp. ```cmake if(SYSTEM_SQLITE_MODERN_CPP) # Search for system installation of sqlite-modern-cpp and use that. find_path(SQLITE_MODERN_CPP_INCLUDE_DIRS "sqlite_modern_cpp.h") message(STATUS "Found sqlite-modern-cpp at ${SQLITE_MODERN_CPP_INCLUDE_DIRS}") target_include_directories( DjInterop PRIVATE SYSTEM ${SQLITE_MODERN_CPP_INCLUDE_DIRS}) else() # Use bundled sqlite-modern-cpp (a header-only library). message(STATUS "Using bundled sqlite-modern-cpp...") target_include_directories( DjInterop PRIVATE SYSTEM ext/sqlite_modern_cpp) endif() ``` -------------------------------- ### C++ Standard and Compiler Configuration Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Enforces C++20 and applies compiler-specific flags for MSVC and GCC/Clang. ```cmake # Require C++20 set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) set(CMAKE_CXX_EXTENSIONS OFF) if(MSVC) add_compile_options("/W4" "/wd4251" "/wd4275" "$<$:/O2>") # Ask MSVC to populate the __cplusplus macro properly. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /Zc:__cplusplus") else() # Disabling -Wunused-variable needed as the library implementation doesn't # use every variable in the public headers. Is there a better way? # Disabling -Wunused-but-set-variable owing to XCode triggering on this # in the bundled SQLite amalgamation. add_compile_options("-Wall" "-Wpedantic" "-Wno-unused-variable" "-Wno-unused-but-set-variable" "-Werror") endif() ``` -------------------------------- ### Define DjInterop Library Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Adds the DjInterop library target and includes all necessary header and source files. ```cmake add_library( DjInterop include/djinterop/album_art.hpp include/djinterop/crate.hpp include/djinterop/database.hpp include/djinterop/djinterop.hpp include/djinterop/engine/engine.hpp include/djinterop/engine/engine_schema.hpp include/djinterop/engine/v2/beat_data_blob.hpp include/djinterop/engine/v2/change_log_table.hpp include/djinterop/engine/v2/engine_library.hpp include/djinterop/engine/v2/information_table.hpp include/djinterop/engine/v2/loops_blob.hpp include/djinterop/engine/v2/overview_waveform_data_blob.hpp include/djinterop/engine/v2/playlist_entity_table.hpp include/djinterop/engine/v2/playlist_table.hpp include/djinterop/engine/v2/quick_cues_blob.hpp include/djinterop/engine/v2/track_data_blob.hpp include/djinterop/engine/v2/track_table.hpp include/djinterop/engine/v3/beat_data_blob.hpp include/djinterop/engine/v3/engine_library.hpp include/djinterop/engine/v3/information_table.hpp include/djinterop/engine/v3/loops_blob.hpp include/djinterop/engine/v3/overview_waveform_data_blob.hpp include/djinterop/engine/v3/performance_data_table.hpp include/djinterop/engine/v3/playlist_entity_table.hpp include/djinterop/engine/v3/playlist_table.hpp include/djinterop/engine/v3/quick_cues_blob.hpp include/djinterop/engine/v3/track_data_blob.hpp include/djinterop/engine/v3/track_table.hpp include/djinterop/exceptions.hpp include/djinterop/musical_key.hpp include/djinterop/pad_color.hpp include/djinterop/performance_data.hpp include/djinterop/playlist.hpp include/djinterop/semantic_version.hpp include/djinterop/stream_helper.hpp include/djinterop/track.hpp include/djinterop/track_snapshot.hpp src/djinterop/crate.cpp src/djinterop/database.cpp src/djinterop/engine/base_engine_library.cpp src/djinterop/engine/base_engine_impl.hpp src/djinterop/engine/encode_decode_utils.cpp src/djinterop/engine/encode_decode_utils.hpp src/djinterop/engine/engine.cpp src/djinterop/engine/engine_library_context.hpp src/djinterop/engine/engine_library_dir_utils.cpp src/djinterop/engine/engine_library_dir_utils.hpp src/djinterop/engine/metadata_types.hpp src/djinterop/engine/schema/schema_1_6_0.cpp src/djinterop/engine/schema/schema_1_6_0.hpp src/djinterop/engine/schema/schema_1_7_1.cpp src/djinterop/engine/schema/schema_1_7_1.hpp src/djinterop/engine/schema/schema_1_9_1.cpp src/djinterop/engine/schema/schema_1_9_1.hpp src/djinterop/engine/schema/schema_1_11_1.cpp src/djinterop/engine/schema/schema_1_11_1.hpp src/djinterop/engine/schema/schema_1_13_0.cpp src/djinterop/engine/schema/schema_1_13_0.hpp src/djinterop/engine/schema/schema_1_13_1.cpp src/djinterop/engine/schema/schema_1_13_1.hpp src/djinterop/engine/schema/schema_1_13_2.cpp src/djinterop/engine/schema/schema_1_13_2.hpp src/djinterop/engine/schema/schema_1_15_0.cpp src/djinterop/engine/schema/schema_1_15_0.hpp src/djinterop/engine/schema/schema_1_17_0.cpp src/djinterop/engine/schema/schema_1_17_0.hpp src/djinterop/engine/schema/schema_1_18_0_desktop.cpp src/djinterop/engine/schema/schema_1_18_0_desktop.hpp src/djinterop/engine/schema/schema_1_18_0_os.cpp src/djinterop/engine/schema/schema_1_18_0_os.hpp src/djinterop/engine/schema/schema_2_18_0.cpp src/djinterop/engine/schema/schema_2_18_0.hpp src/djinterop/engine/schema/schema_2_20_1.cpp src/djinterop/engine/schema/schema_2_20_1.hpp src/djinterop/engine/schema/schema_2_20_2.cpp src/djinterop/engine/schema/schema_2_20_2.hpp src/djinterop/engine/schema/schema_2_20_3.cpp src/djinterop/engine/schema/schema_2_20_3.hpp src/djinterop/engine/schema/schema_2_21_0.cpp src/djinterop/engine/schema/schema_2_21_0.hpp src/djinterop/engine/schema/schema_2_21_1.cpp src/djinterop/engine/schema/schema_2_21_1.hpp src/djinterop/engine/schema/schema_2_21_2.cpp src/djinterop/engine/schema/schema_2_21_2.hpp src/djinterop/engine/schema/schema_3_0_0.cpp src/djinterop/engine/schema/schema_3_0_0.hpp src/djinterop/engine/schema/schema_3_0_1.cpp src/djinterop/engine/schema/schema_3_0_1.hpp src/djinterop/engine/schema/schema_3_0_2.cpp src/djinterop/engine/schema/schema_3_0_2.hpp src/djinterop/engine/schema/schema.cpp src/djinterop/engine/schema/schema.hpp ) ``` -------------------------------- ### Define DjInterop Compile Definitions Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Adds the DJINTEROP_SOURCE definition to the DjInterop target. ```cmake target_compile_definitions(DjInterop PUBLIC DJINTEROP_SOURCE) ``` -------------------------------- ### Detect DjInterop Library Type Source: https://github.com/xsco/libdjinterop/blob/main/CMakeLists.txt Checks if the DjInterop library is built as a static library and sets a flag accordingly. ```cmake get_target_property(DJINTEROP_LIBRARY_TYPE DjInterop TYPE) if(DJINTEROP_LIBRARY_TYPE STREQUAL "STATIC_LIBRARY") set(DJINTEROP_STATIC ON) endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.