Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

Commit

Permalink
CMake install and exports settings
Browse files Browse the repository at this point in the history
  • Loading branch information
seanmiddleditch committed Feb 25, 2019
1 parent 6e7402f commit 9b0910b
Show file tree
Hide file tree
Showing 2 changed files with 79 additions and 1 deletion.
16 changes: 15 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ project(formatxx
)

option(FORMATXX_BUILD_TESTS "Build formatxx tests" ON)
option(BUILD_SHARED_LIBS "Build shared libraries" OFF)

set(FORMATXX_PUBLIC_HEADERS
include/formatxx/buffered_writer.h
Expand Down Expand Up @@ -37,14 +38,27 @@ set(FORMATXX_FILES ${FORMATXX_PUBLIC_HEADERS} ${FORMATXX_PRIVATE_HEADERS} ${FORM

add_library(formatxx ${FORMATXX_FILES})
target_compile_features(formatxx PUBLIC cxx_std_17)
target_include_directories(formatxx PUBLIC "include")
target_include_directories(formatxx PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include/formatxx>
)
set_target_properties(formatxx PROPERTIES
DEFINE_SYMBOL FORMATXX_EXPORT
CXX_VISIBILITY_PRESET hidden
VISIBILITY_INLINES_HIDDEN ON
)
source_group("Header Files\\_detail" FILES ${FORMATXX_PRIVATE_HEADERS})

install(TARGETS formatxx EXPORT formatxx-targets
ARCHIVE DESTINATION lib
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
)
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_PREFIX})
install(EXPORT formatxx-targets DESTINATION share/formatxx/cmake)

export(TARGETS formatxx FILE formatxx-exports.cmake)

if(FORMATXX_BUILD_TESTS)
enable_testing()
add_executable(formatxx_tests ${FORMATXX_TESTS})
Expand Down
64 changes: 64 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{
"configurations": [
{
"name": "x64-Release",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "BUILD_SHARED_LIBS",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Debug",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": [
{
"name": "BUILD_SHARED_LIBS",
"value": "True",
"type": "BOOL"
}
]
},
{
"name": "x64-Release-Static",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
},
{
"name": "x64-Debug-Static",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\build\\${name}",
"installRoot": "${env.USERPROFILE}\\CMakeBuilds\\${workspaceHash}\\install\\${name}",
"cmakeCommandArgs": "",
"buildCommandArgs": "-v",
"ctestCommandArgs": "",
"inheritEnvironments": [ "msvc_x64_x64" ],
"variables": []
}
]
}

0 comments on commit 9b0910b

Please sign in to comment.