### CMake Export and Configuration Installation Source: https://github.com/nextgis-borsch/lib_opencad/blob/master/lib/CMakeLists.txt This CMake script handles the export of build targets and the installation of package configuration files. It creates a CMake export file and a `Config.cmake` file from templates, then installs them into the appropriate configuration directory. The installation is conditional based on build flags like `SKIP_INSTALL_LIBRARIES` and `SKIP_INSTALL_ALL`. ```cmake # Add all targets to the build-tree export set export(TARGETS ${INSTALL_TARGETS} FILE ${PROJECT_BINARY_DIR}/${PACKAGE_UPPER_NAME}Targets.cmake) # Create the Config.cmake file configure_file(${PROJECT_SOURCE_DIR}/cmake/PackageConfig.cmake.in ${PROJECT_BINARY_DIR}/${PACKAGE_UPPER_NAME}Config.cmake @ONLY) if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL) # Install the Config.cmake install(FILES ${PROJECT_BINARY_DIR}/${PACKAGE_UPPER_NAME}Config.cmake DESTINATION ${INSTALL_CMAKECONF_DIR} COMPONENT dev) # Install the export set for use with the install-tree install(EXPORT ${PACKAGE_UPPER_NAME}Targets DESTINATION ${INSTALL_CMAKECONF_DIR} COMPONENT dev) endif() ``` -------------------------------- ### OpenCAD Library Build Configuration Source: https://github.com/nextgis-borsch/lib_opencad/blob/master/CMakeLists.txt This CMakeLists.txt file configures the build process for the OpenCAD library. It sets up installation paths, handles macOS framework specifics, enforces C++11 standard, includes subdirectories for the library, applications, and tests, and configures packaging using CPack. ```cmake set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake ${CMAKE_MODULE_PATH}) if(OSX_FRAMEWORK AND (BUILD_SHARED_LIBS OR BUILD_STATIC_LIBS)) message(FATAL_ERROR "Only OSX_FRAMEWORK key or any or both BUILD_SHARED_LIBS and BUILD_STATIC_LIBS keys are permitted") endif() if(OSX_FRAMEWORK) set(INSTALL_BIN_DIR "bin" CACHE INTERNAL "Installation directory for executables" FORCE) set(INSTALL_LIB_DIR "Library/Frameworks" CACHE INTERNAL "Installation directory for libraries" FORCE) set(INSTALL_INC_DIR "${INSTALL_LIB_DIR}/${PROJECT_NAME}.framework/Headers" CACHE INTERNAL "Installation directory for headers" FORCE) set(SKIP_INSTALL_EXECUTABLES OFF) set(SKIP_INSTALL_EXPORT ON) set(SKIP_INSTALL_HEADERS ON) set(SKIP_INSTALL_FILES ON) set(SKIP_INSTALL_DOCS OFF) set(CMAKE_MACOSX_RPATH ON) set(INSTALL_CMAKECONF_DIR ${INSTALL_LIB_DIR}/${PROJECT_NAME}.framework/Resources/CMake CACHE INTERNAL "Installation directory for cmake config files" FORCE) else() include(GNUInstallDirs) set(INSTALL_BIN_DIR ${CMAKE_INSTALL_BINDIR} CACHE INTERNAL "Installation directory for executables" FORCE) set(INSTALL_LIB_DIR ${CMAKE_INSTALL_LIBDIR} CACHE INTERNAL "Installation directory for libraries" FORCE) set(INSTALL_INC_DIR ${CMAKE_INSTALL_INCLUDEDIR}/opencad CACHE INTERNAL "Installation directory for headers" FORCE) set(INSTALL_DOC_DIR ${CMAKE_INSTALL_DOCDIR} CACHE INTERNAL "Installation directory for doc pages" FORCE) set(INSTALL_CMAKECONF_DIR ${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/CMake CACHE INTERNAL "Installation directory for cmake config files" FORCE) endif() set(PACKAGE_NAME ${PROJECT_NAME}) string(TOUPPER ${PACKAGE_NAME} PACKAGE_UPPER_NAME) include(util) check_version(OCAD_MAJOR_VERSION OCAD_MINOR_VERSION OCAD_REV_VERSION) set(VERSION ${OCAD_MAJOR_VERSION}.${OCAD_MINOR_VERSION}.${OCAD_REV_VERSION}) set(SOVERSION 1) if(OSX_FRAMEWORK) set(FRAMEWORK_VERSION "${OCAD_MAJOR_VERSION}") # set(INSTALL_INC_DIR "${INSTALL_LIB_DIR}/${PROJECT_NAME}.framework/Versions/${FRAMEWORK_VERSION}/Headers" CACHE INTERNAL "Installation directory for headers" FORCE) set(INSTALL_DOC_DIR "${INSTALL_LIB_DIR}/${PROJECT_NAME}.framework/Versions/${FRAMEWORK_VERSION}/Resources/docs") endif() report_version(${PROJECT_NAME} ${VERSION}) if(CMAKE_BUILD_TYPE STREQUAL Debug) add_definitions(-D_DEBUG) endif() configure_file(${CMAKE_MODULE_PATH}/uninstall.cmake.in ${CMAKE_BINARY_DIR}/cmake_uninstall.cmake IMMEDIATE @ONLY) enable_testing() include(FindAnyProject) if(NOT MSVC) include(CheckCXXCompilerFlag) CHECK_CXX_COMPILER_FLAG("-std=c++11" COMPILER_SUPPORTS_CXX11) if(NOT COMPILER_SUPPORTS_CXX11) message(FATAL_ERROR "C++11 support required") endif() endif() if(MSVC AND MSVC_VERSION LESS 1700) message(FATAL_ERROR "C++11 support required. The compiled version is less than VC 2012.") endif() if(CMAKE_VERSION VERSION_LESS "3.1") if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU") set(CMAKE_CXX_FLAGS "-std=c++11 ${CMAKE_CXX_FLAGS}") endif() else() set(CMAKE_CXX_STANDARD 11) set(CMAKE_CXX_STANDARD_REQUIRED ON) endif() set(TARGET_LINK) add_subdirectory(lib) option(BUILD_APPS "Build console applications" ON) if(BUILD_APPS) add_subdirectory(apps) endif() add_subdirectory(tests) set(DOC_FILES LICENSE README.md) install (FILES ${DOC_FILES} DESTINATION ${INSTALL_DOC_DIR} COMPONENT documents OPTIONAL) # uninstall add_custom_target(uninstall COMMAND ${CMAKE_COMMAND} -P ${CMAKE_CURRENT_BINARY_DIR}/cmake_uninstall.cmake) # Export package =============================================================== if(REGISTER_PACKAGE) # Export the package for use from the build-tree # (this registers the build-tree with a global CMake-registry) export(PACKAGE ${PACKAGE_UPPER_NAME}) endif() # Archiving ==================================================================== set(CPACK_PACKAGE_NAME "${PACKAGE_NAME}") set(CPACK_PACKAGE_VENDOR "${PACKAGE_VENDOR}") set(CPACK_PACKAGE_VERSION "${VERSION}") set(CPACK_PACKAGE_DESCRIPTION_SUMMARY "${PACKAGE_NAME} Installation") set(CPACK_PACKAGE_RELOCATABLE TRUE) set(CPACK_ARCHIVE_COMPONENT_INSTALL ON) set(CPACK_GENERATOR "ZIP") set(CPACK_MONOLITHIC_INSTALL ON) set(CPACK_STRIP_FILES TRUE) # Get cpack zip archive name get_cpack_filename(${VERSION} PROJECT_CPACK_FILENAME) set(CPACK_PACKAGE_FILE_NAME ${PROJECT_CPACK_FILENAME}) include(CPack) ``` -------------------------------- ### CMake Build Configuration for lib_opencad Source: https://github.com/nextgis-borsch/lib_opencad/blob/master/apps/CMakeLists.txt This snippet defines the CMake build process for the lib_opencad project. It sets the minimum required CMake version, defines the project name, configures platform-specific C++ flags (like disabling warnings on Windows), includes necessary directories, lists source files, defines the executable target 'cadinfo', links against specified libraries, and sets target properties for different operating systems. Finally, it handles the installation of the executable. ```cmake cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(apps) if(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") endif() include_directories(${CMAKE_SOURCE_DIR}/lib) set(CSOURCES cadinfo.cpp ) add_executable(cadinfo ${CSOURCES}) target_link_libraries(cadinfo ${TARGET_LINK}) if(OSX_FRAMEWORK) set_target_properties(cadinfo PROPERTIES INSTALL_RPATH "@executable_path/../../Library/Frameworks") elseif(WIN32) set_target_properties(cadinfo PROPERTIES LINK_FLAGS "/ignore:4099") endif() if(NOT SKIP_INSTALL_EXECUTABLES AND NOT SKIP_INSTALL_ALL ) install(TARGETS cadinfo RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT applications ARCHIVE DESTINATION ${INSTALL_LIB_DIR} COMPONENT applications LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT applications ) endif() ``` -------------------------------- ### CMake Build Configuration for libopencad Source: https://github.com/nextgis-borsch/lib_opencad/blob/master/lib/CMakeLists.txt This CMake script configures the build process for the libopencad library. It sets up C++ compiler flags, defines source and header files, creates shared and static library targets, and manages installation paths for headers and libraries across different platforms. ```CMake cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) include_directories(${CMAKE_CURRENT_SOURCE_DIR}) if(UNIX) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC") elseif(WIN32) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /wd4251") endif() set(OBJ_LIB) add_subdirectory(dwg) set(HHEADERS opencad.h opencad_api.h cadfile.h cadfileio.h cadheader.h cadclasses.h cadtables.h cadgeometry.h cadlayer.h cadcolors.h caddictionary.h cadobjects.h) set(HHEADER_PRIV cadfilestreamio.h ) set(CSOURCES opencad.cpp cadcolors.cpp cadfile.cpp cadfileio.cpp cadfilestreamio.cpp cadheader.cpp cadclasses.cpp cadtables.cpp cadgeometry.cpp cadobjects.cpp cadlayer.cpp caddictionary.cpp) set(LIB_NAME ${PROJECT_NAME}) if(BUILD_SHARED_LIBS) add_library(${LIB_NAME} SHARED ${CSOURCES} ${HHEADERS} ${HHEADER_PRIV} ${OBJ_LIB}) set_target_properties (${LIB_NAME} PROPERTIES VERSION ${VERSION} SOVERSION ${SOVERSION} DEFINE_SYMBOL OCAD_EXPORTS ) if(MSVC) set_target_properties(${LIB_NAME} PROPERTIES IMPORT_SUFFIX "_i.lib" LINK_FLAGS "/ignore:4049 /ignore:4217") endif() elseif(OSX_FRAMEWORK) add_library(${LIB_NAME} SHARED ${CSOURCES} ${HHEADERS} ${HHEADER_PRIV} ${OBJ_LIB}) set_target_properties(${LIB_NAME} PROPERTIES FRAMEWORK TRUE FRAMEWORK_VERSION ${FRAMEWORK_VERSION} MACOSX_FRAMEWORK_SHORT_VERSION_STRING ${VERSION} MACOSX_FRAMEWORK_BUNDLE_VERSION ${VERSION} MACOSX_FRAMEWORK_IDENTIFIER org.opencad.opencad XCODE_ATTRIBUTE_INSTALL_PATH "@rpath" PUBLIC_HEADER "${HHEADERS}" VERSION ${VERSION} SOVERSION ${SOVERSION} ) else() add_definitions(-DOCAD_STATIC) add_library(${LIB_NAME} STATIC ${CSOURCES} ${HHEADERS} ${HHEADER_PRIV} ${OBJ_LIB}) endif() set(INSTALL_TARGETS ${LIB_NAME}) if(BUILD_SHARED_LIBS AND BUILD_STATIC_LIBS) add_library(${LIB_NAME}static STATIC ${CSOURCES} ${HHEADERS} ${HHEADER_PRIV} ${OBJ_LIB}) set(INSTALL_TARGETS ${INSTALL_TARGETS} ${LIB_NAME}static) if(WIN32) set_target_properties(${LIB_NAME}static PROPERTIES OUTPUT_NAME ${LIB_NAME}_i) else() set_target_properties(${LIB_NAME}static PROPERTIES OUTPUT_NAME ${LIB_NAME}) endif() set_target_properties(${LIB_NAME}static PROPERTIES CLEAN_DIRECT_OUTPUT 1) endif() set(TARGET_LINK ${TARGET_LINK} ${LIB_NAME} PARENT_SCOPE) if(NOT SKIP_INSTALL_LIBRARIES AND NOT SKIP_INSTALL_ALL ) install(TARGETS ${INSTALL_TARGETS} EXPORT ${PACKAGE_UPPER_NAME}Targets RUNTIME DESTINATION ${INSTALL_BIN_DIR} COMPONENT libraries ARCHIVE DESTINATION ${INSTALL_LIB_DIR} COMPONENT libraries LIBRARY DESTINATION ${INSTALL_LIB_DIR} COMPONENT libraries INCLUDES DESTINATION ${INSTALL_INC_DIR} FRAMEWORK DESTINATION ${INSTALL_LIB_DIR} ) endif() if(NOT SKIP_INSTALL_HEADERS AND NOT SKIP_INSTALL_ALL) install(FILES ${HHEADERS} DESTINATION "${INSTALL_INC_DIR}" COMPONENT headers) endif() # Add path to includes to build-tree export target_include_directories(${LIB_NAME} PUBLIC $ $ ) ``` -------------------------------- ### CMake Build Configuration for lib_opencad Source: https://github.com/nextgis-borsch/lib_opencad/blob/master/lib/dwg/CMakeLists.txt This snippet details the CMake build configuration for the lib_opencad library. It specifies the minimum CMake version, project name, source and header files, and how to build the library as an object library. ```CMake cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(dwg) set(HHEADERS io.h r2000.h) set(CSOURCES io.cpp r2000.cpp ) add_library(${PROJECT_NAME} OBJECT ${CSOURCES} ${HHEADERS}) set(OBJ_LIB ${OBJ_LIB} $ PARENT_SCOPE) ``` -------------------------------- ### CMake Configuration for lib_opencad Source: https://github.com/nextgis-borsch/lib_opencad/blob/master/CMakeLists.txt This snippet configures the lib_opencad project using CMake. It sets the minimum required CMake version, defines the project name, and configures package vendor and bug report details. It also enables colored Makefiles for better output readability. ```CMake cmake_minimum_required(VERSION 2.8.12 FATAL_ERROR) project(opencad) if(NOT DEFINED PACKAGE_VENDOR) set(PACKAGE_VENDOR NextGIS) endif() if(NOT DEFINED PACKAGE_BUGREPORT) set(PACKAGE_BUGREPORT info@nextgis.com) endif() # Some init settings set(CMAKE_COLOR_MAKEFILE ON) ``` -------------------------------- ### CMake Build Configuration for lib_opencad Source: https://github.com/nextgis-borsch/lib_opencad/blob/master/tests/CMakeLists.txt This snippet details the CMake build configuration for the lib_opencad project. It includes setting build options like BUILD_TESTING, finding external libraries such as GTest and Threads, and configuring targets for executables like 'io_test' and 'geometry_test'. It also handles platform-specific post-build commands for Windows. ```cmake option(BUILD_TESTING "Build unit tests" OFF) if(BUILD_TESTING) set(WITH_GTest ON CACHE BOOL "Google test on") set(WITH_GTest_EXTERNAL ON CACHE BOOL "Google test external on") find_anyproject(GTest REQUIRED) include_directories(${PROJECT_SOURCE_DIR}/lib) set(TARGET_LINK_LIB ${TARGET_LINK_LIB} ${TARGET_LINK}) find_package(Threads) if(CMAKE_THREAD_LIBS_INIT) set(TARGET_LINK_LIB ${TARGET_LINK_LIB} ${CMAKE_THREAD_LIBS_INIT} ${CMAKE_DL_LIBS}) endif() find_library(M_LIB m) if(M_LIB) set(TARGET_LINK_LIB ${TARGET_LINK_LIB} ${M_LIB}) endif() file(COPY data DESTINATION ${CMAKE_CURRENT_BINARY_DIR}) file(COPY data/r2000 DESTINATION ${CMAKE_CURRENT_BINARY_DIR}/data) add_executable(io_test io_check.cpp ${CMAKE_SOURCE_DIR}/lib/dwg/io.cpp ) target_link_extlibraries(io_test) add_test( io_test io_test ) add_executable(geometry_test reading_geometries.cpp) target_link_extlibraries(geometry_test) add_test( geometry_test geometry_test ) if(WIN32) set(IMPORTED_WIN_DLLS "${CMAKE_BINARY_DIR}\third-party\install\bin\gtest.dll" "${CMAKE_BINARY_DIR}\third-party\install\bin\gtest_main.dll" $ ) foreach(IMPORTED_WIN_DLL ${IMPORTED_WIN_DLLS}) add_custom_command(TARGET geometry_test POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy ${IMPORTED_WIN_DLL} $ COMMENT "Copy ${IMPORTED_WIN_DLL} to test directory" VERBATIM ) endforeach() endif() endif() ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.