Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added proper install configuration for cmake #28

Merged
merged 1 commit into from
Mar 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 49 additions & 26 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -69,38 +69,13 @@ find_package( Threads REQUIRED )
# Xerces-c
find_package( XercesC REQUIRED )

if ( NOT XercesC_FOUND )
set( XercesC_INCLUDE_DIR "" CACHE PATH "Xerces include directory" )
endif()

if ( WIN32 )
option( USING_STATIC_XERCES "Turn on if you are linking with Xerces as a static lib" OFF )

if ( USING_STATIC_XERCES )
add_definitions( -DXERCES_STATIC_LIBRARY )
endif()
endif()

set( XML_INCLUDE_DIRS ${XercesC_INCLUDE_DIR} )

add_definitions(-DREVISION_ID="${PROJECT_NAME}-${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}-${${PROJECT_NAME}_BUILD_TAG}")

include_directories(
${PROJECT_BINARY_DIR}/include
include
src/
${XML_INCLUDE_DIRS}
)

# CRCpp from here: https://github.com/d-bahr/CRCpp
add_definitions( -DCRCPP_USE_CPP11 )
add_definitions( -DCRCPP_BRANCHLESS )
include_directories( contrib/CRCpp/inc )

#
# The reference implementation
#

# Target
add_library( E57Format STATIC
src/CheckedFile.h
src/CheckedFile.cpp
Expand Down Expand Up @@ -130,23 +105,71 @@ add_library( E57Format STATIC
include/E57Format.h
contrib/CRCpp/inc/CRC.h
)

# Target properties
set_target_properties( E57Format PROPERTIES
DEBUG_POSTFIX "-d"
POSITION_INDEPENDENT_CODE ON
)

# Target definitions
target_compile_definitions( E57Format
PRIVATE
-DCRCPP_USE_CPP11
-DCRCPP_BRANCHLESS
-DREVISION_ID="${PROJECT_NAME}-${${PROJECT_NAME}_MAJOR_VERSION}.${${PROJECT_NAME}_MINOR_VERSION}.${${PROJECT_NAME}_PATCH_VERSION}-${${PROJECT_NAME}_BUILD_TAG}"
)

if ( WIN32 )
option( USING_STATIC_XERCES "Turn on if you are linking with Xerces as a static lib" OFF )
if ( USING_STATIC_XERCES )
add_compile_definitions( -DXERCES_STATIC_LIBRARY )
endif()
endif()

# Target includes
target_include_directories( E57Format
PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
$<INSTALL_INTERFACE:include/E57Format>
PRIVATE
src/
contrib/CRCpp/inc
)

# Target Libraries
target_link_libraries( E57Format PRIVATE XercesC::XercesC )

#
# Install section
#

install(
TARGETS
E57Format
EXPORT
E57Format-export
ARCHIVE DESTINATION lib
)

install(
FILES
include/E57Exception.h
include/E57Format.h
DESTINATION include/E57Format
)

# CMake package files
install(
EXPORT
E57Format-export
DESTINATION lib/cmake/E57Format
)

install(
FILES
${CMAKE_CURRENT_SOURCE_DIR}/cmake/E57Format-config.cmake
DESTINATION
lib/cmake/E57Format
)
4 changes: 4 additions & 0 deletions cmake/E57Format-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include(CMakeFindDependencyMacro)

find_dependency(XercesC REQUIRED)
include(${CMAKE_CURRENT_LIST_DIR}/E57Format-export.cmake)