mirror of
https://github.com/Kitware/CMake.git
synced 2026-08-03 22:30:29 +00:00
Tutorial: Install correctly when built statically
When built statically we failed to install the SqrtLibrary
This commit is contained in:
@@ -57,7 +57,11 @@ set_property(TARGET MathFunctions PROPERTY VERSION "1.0.0")
|
|||||||
set_property(TARGET MathFunctions PROPERTY SOVERSION "1")
|
set_property(TARGET MathFunctions PROPERTY SOVERSION "1")
|
||||||
|
|
||||||
# install rules
|
# install rules
|
||||||
install(TARGETS MathFunctions tutorial_compiler_flags
|
set(installable_libs MathFunctions tutorial_compiler_flags)
|
||||||
|
if(TARGET SqrtLibrary)
|
||||||
|
list(APPEND installable_libs SqrtLibrary)
|
||||||
|
endif()
|
||||||
|
install(TARGETS ${installable_libs}
|
||||||
DESTINATION lib
|
DESTINATION lib
|
||||||
EXPORT MathFunctionsTargets)
|
EXPORT MathFunctionsTargets)
|
||||||
install(FILES MathFunctions.h DESTINATION include)
|
install(FILES MathFunctions.h DESTINATION include)
|
||||||
|
|||||||
@@ -47,5 +47,9 @@ endif()
|
|||||||
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
|
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
|
||||||
|
|
||||||
# install rules
|
# install rules
|
||||||
install(TARGETS MathFunctions DESTINATION lib)
|
set(installable_libs MathFunctions)
|
||||||
|
if(TARGET SqrtLibrary)
|
||||||
|
list(APPEND installable_libs SqrtLibrary)
|
||||||
|
endif()
|
||||||
|
install(TARGETS ${installable_libs} DESTINATION lib)
|
||||||
install(FILES MathFunctions.h DESTINATION include)
|
install(FILES MathFunctions.h DESTINATION include)
|
||||||
|
|||||||
@@ -51,5 +51,9 @@ target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
|
|||||||
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
|
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
|
||||||
|
|
||||||
# install rules
|
# install rules
|
||||||
install(TARGETS MathFunctions DESTINATION lib)
|
set(installable_libs MathFunctions tutorial_compiler_flags)
|
||||||
|
if(TARGET SqrtLibrary)
|
||||||
|
list(APPEND installable_libs SqrtLibrary)
|
||||||
|
endif()
|
||||||
|
install(TARGETS ${installable_libs} DESTINATION lib)
|
||||||
install(FILES MathFunctions.h DESTINATION include)
|
install(FILES MathFunctions.h DESTINATION include)
|
||||||
|
|||||||
@@ -53,7 +53,11 @@ target_link_libraries(MathFunctions PUBLIC tutorial_compiler_flags)
|
|||||||
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
|
target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
|
||||||
|
|
||||||
# install rules
|
# install rules
|
||||||
install(TARGETS MathFunctions tutorial_compiler_flags
|
set(installable_libs MathFunctions tutorial_compiler_flags)
|
||||||
|
if(TARGET SqrtLibrary)
|
||||||
|
list(APPEND installable_libs SqrtLibrary)
|
||||||
|
endif()
|
||||||
|
install(TARGETS ${installable_libs}
|
||||||
DESTINATION lib
|
DESTINATION lib
|
||||||
EXPORT MathFunctionsTargets)
|
EXPORT MathFunctionsTargets)
|
||||||
install(FILES MathFunctions.h DESTINATION include)
|
install(FILES MathFunctions.h DESTINATION include)
|
||||||
|
|||||||
@@ -675,9 +675,9 @@ The first step is to update the starting section of the top-level
|
|||||||
|
|
||||||
Now that we have made MathFunctions always be used, we will need to update
|
Now that we have made MathFunctions always be used, we will need to update
|
||||||
the logic of that library. So, in ``MathFunctions/CMakeLists.txt`` we need to
|
the logic of that library. So, in ``MathFunctions/CMakeLists.txt`` we need to
|
||||||
create a SqrtLibrary that will conditionally be built when ``USE_MYMATH`` is
|
create a SqrtLibrary that will conditionally be built and installed when
|
||||||
enabled. Now, since this is a tutorial, we are going to explicitly require
|
``USE_MYMATH`` is enabled. Now, since this is a tutorial, we are going to
|
||||||
that SqrtLibrary is built statically.
|
explicitly require that SqrtLibrary is built statically.
|
||||||
|
|
||||||
The end result is that ``MathFunctions/CMakeLists.txt`` should look like:
|
The end result is that ``MathFunctions/CMakeLists.txt`` should look like:
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user