Skip to content

Commit

Permalink
Merge pull request #43 from asmaloney/optional_install
Browse files Browse the repository at this point in the history
Only try to install if we are not a submodule
  • Loading branch information
graeme-hill authored Jan 28, 2019
2 parents 48daf4f + 0f27531 commit b151b7d
Showing 1 changed file with 32 additions and 29 deletions.
61 changes: 32 additions & 29 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,6 @@ if(NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE "Release")
endif()

include(GNUInstallDirs)
set(CROSSGUID_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(CROSSGUID_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
set(CROSSGUID_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(CROSSGUID_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(CROSSGUID_FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")

set(CROSSGUID_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/crossguid/cmake")
set(CROSSGUID_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/crossguid")

add_library(crossguid ${CMAKE_CURRENT_SOURCE_DIR}/src/guid.cpp)
target_include_directories(crossguid PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
Expand Down Expand Up @@ -65,25 +55,38 @@ set_target_properties(crossguid
PROPERTIES
DEBUG_POSTFIX ${CMAKE_DEBUG_POSTFIX})

# Install target
install(TARGETS crossguid EXPORT crossguidTargets
RUNTIME DESTINATION ${CROSSGUID_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${CROSSGUID_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${CROSSGUID_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${CROSSGUID_FRAMEWORK_INSTALL_DIR})

# Install headers
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION ${CROSSGUID_INC_INSTALL_DIR})

# Make cmake config files for all targets
install(EXPORT crossguidTargets
DESTINATION ${CROSSGUID_CMAKE_CONFIG_INSTALL_DIR}
FILE crossguid-config.cmake)

# Install readme and license
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_SOURCE_DIR}/README.md"
DESTINATION ${CROSSGUID_ADDITIONAL_FILES_INSTALL_DIR})
if (${CMAKE_SOURCE_DIR} STREQUAL ${CMAKE_CURRENT_SOURCE_DIR})
include(GNUInstallDirs)

set(CROSSGUID_INC_INSTALL_DIR "${CMAKE_INSTALL_INCLUDEDIR}")
set(CROSSGUID_RUNTIME_INSTALL_DIR "${CMAKE_INSTALL_BINDIR}")
set(CROSSGUID_LIBRARY_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(CROSSGUID_ARCHIVE_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")
set(CROSSGUID_FRAMEWORK_INSTALL_DIR "${CMAKE_INSTALL_LIBDIR}")

set(CROSSGUID_CMAKE_CONFIG_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/crossguid/cmake")
set(CROSSGUID_ADDITIONAL_FILES_INSTALL_DIR "${CMAKE_INSTALL_DATADIR}/crossguid")

# Install target
install(TARGETS crossguid EXPORT crossguidTargets
RUNTIME DESTINATION ${CROSSGUID_RUNTIME_INSTALL_DIR}
LIBRARY DESTINATION ${CROSSGUID_LIBRARY_INSTALL_DIR}
ARCHIVE DESTINATION ${CROSSGUID_ARCHIVE_INSTALL_DIR}
FRAMEWORK DESTINATION ${CROSSGUID_FRAMEWORK_INSTALL_DIR})

# Install headers
install(DIRECTORY "${CMAKE_CURRENT_SOURCE_DIR}/include/"
DESTINATION ${CROSSGUID_INC_INSTALL_DIR})

# Make cmake config files for all targets
install(EXPORT crossguidTargets
DESTINATION ${CROSSGUID_CMAKE_CONFIG_INSTALL_DIR}
FILE crossguid-config.cmake)

# Install readme and license
install(FILES "${CMAKE_CURRENT_SOURCE_DIR}/LICENSE" "${CMAKE_CURRENT_SOURCE_DIR}/README.md"
DESTINATION ${CROSSGUID_ADDITIONAL_FILES_INSTALL_DIR})
endif()

if (CROSSGUID_TESTS)
add_executable(crossguid-test test/TestMain.cpp test/Test.cpp)
Expand Down

0 comments on commit b151b7d

Please sign in to comment.