Commit 966505db authored by Nicolas Michon's avatar Nicolas Michon

Cmake changes for cross-compilation and better use of imported targets

parent 5b954d9b
......@@ -164,6 +164,11 @@ if(ENABLE_STATIC)
if(CURSES_LIBRARIES)
target_link_libraries(bcunit-static INTERFACE ${CURSES_LIBRARIES})
endif()
target_include_directories(bcunit-static PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/BCUnit/Headers/>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/BCUnit/Headers/>
)
install(TARGETS bcunit-static EXPORT BcUnitTargets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
......@@ -172,6 +177,11 @@ endif()
if(ENABLE_SHARED)
add_library(bcunit SHARED ${SOURCE_FILES})
set_target_properties(bcunit PROPERTIES VERSION 1.0.1)
target_include_directories(bcunit PUBLIC
$<INSTALL_INTERFACE:include>
$<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/BCUnit/Headers/>
$<BUILD_INTERFACE:${CMAKE_BINARY_DIR}/BCUnit/Headers/>
)
if(CURSES_LIBRARIES)
target_link_libraries(bcunit ${CURSES_LIBRARIES})
endif()
......
......@@ -28,6 +28,8 @@
# BCUNIT_INCLUDE_DIRS - the bcunit include directory
# BCUNIT_LIBRARIES - The libraries needed to use bcunit
@PACKAGE_INIT@
include("${CMAKE_CURRENT_LIST_DIR}/BcUnitTargets.cmake")
if(@ENABLE_SHARED@)
......@@ -45,8 +47,6 @@ get_target_property(BCUNIT_INCLUDE_DIRS ${BCUNIT_TARGETNAME} INTERFACE_INCLUDE_D
if(NOT BCUNIT_INCLUDE_DIRS)
set(BCUNIT_INCLUDE_DIRS )
endif()
list(INSERT BCUNIT_INCLUDE_DIRS 0 "@CMAKE_INSTALL_FULL_INCLUDEDIR@")
list(REMOVE_DUPLICATES BCUNIT_INCLUDE_DIRS)
set(BCUNIT_FOUND 1)
......@@ -20,7 +20,7 @@
#
############################################################################
cmake_minimum_required(VERSION 2.8.12)
cmake_minimum_required(VERSION 3.1)
set(CMAKE_MACOSX_RPATH ON) # Before cmake 3.0.0, MACOSX_RPATH was not set to ON by default - however this is no good reason to not enable it by default
project(BCunit C)
......@@ -88,12 +88,9 @@ endif()
add_subdirectory(build)
include_directories(
BCUnit/Headers
${CMAKE_CURRENT_BINARY_DIR}
${CMAKE_CURRENT_BINARY_DIR}/BCUnit/Headers
${CMAKE_CURRENT_BINARY_DIR}
)
add_subdirectory(BCUnit)
if(ENABLE_DOC)
add_subdirectory(doc)
......@@ -106,6 +103,7 @@ endif()
include(CMakePackageConfigHelpers)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
write_basic_package_version_file(
"${CMAKE_CURRENT_BINARY_DIR}/BcUnitConfigVersion.cmake"
VERSION ${PACKAGE_VERSION}
......@@ -114,9 +112,13 @@ write_basic_package_version_file(
export(EXPORT BcUnitTargets
FILE "${CMAKE_CURRENT_BINARY_DIR}/BcUnitTargets.cmake"
)
configure_file(BcUnitConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/BcUnitConfig.cmake" @ONLY)
set(CONFIG_PACKAGE_LOCATION "${CMAKE_INSTALL_DATADIR}/${PROJECT_NAME}/cmake")
configure_package_config_file(BcUnitConfig.cmake.in
"${CMAKE_CURRENT_BINARY_DIR}/BcUnitConfig.cmake"
INSTALL_DESTINATION ${CONFIG_PACKAGE_LOCATION}
NO_SET_AND_CHECK_MACRO
)
install(EXPORT BcUnitTargets
FILE BcUnitTargets.cmake
DESTINATION ${CONFIG_PACKAGE_LOCATION}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment