mirror of
https://github.com/ttroy50/cmake-examples.git
synced 2025-12-18 12:14:36 +03:00
Update to minimum CMake 3.5
And modernise some examples.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
cmake_minimum_required (VERSION 3.0)
|
||||
cmake_minimum_required (VERSION 3.5)
|
||||
|
||||
project(subprojects)
|
||||
|
||||
|
||||
@@ -145,7 +145,7 @@ is added as a dependency.
|
||||
----
|
||||
target_link_libraries(subbinary
|
||||
PUBLIC
|
||||
sublibrary1
|
||||
sublibrary1
|
||||
)
|
||||
----
|
||||
|
||||
@@ -164,7 +164,7 @@ To reference the alias, just it as follows:
|
||||
[source,cmake]
|
||||
----
|
||||
target_link_libraries(subbinary
|
||||
sublibrary1
|
||||
sub::lib2
|
||||
)
|
||||
----
|
||||
|
||||
|
||||
@@ -1,11 +1,7 @@
|
||||
project(subbinary)
|
||||
|
||||
set(SOURCES
|
||||
main.cpp
|
||||
)
|
||||
|
||||
# Create the executable
|
||||
add_executable(${PROJECT_NAME} ${SOURCES})
|
||||
add_executable(${PROJECT_NAME} main.cpp)
|
||||
|
||||
# Link the static library from subproject1 using it's alias sub::lib1
|
||||
# Link the header only library from subproject2 using it's alias sub::lib2
|
||||
|
||||
@@ -1,13 +1,8 @@
|
||||
# Set the project name
|
||||
project (sublibrary1)
|
||||
|
||||
# Create a sources variable with a link to all cpp files to compile
|
||||
set(SOURCES
|
||||
src/sublib1.cpp
|
||||
)
|
||||
|
||||
# Add a library with the above sources
|
||||
add_library(${PROJECT_NAME} ${SOURCES})
|
||||
add_library(${PROJECT_NAME} src/sublib1.cpp)
|
||||
add_library(sub::lib1 ALIAS ${PROJECT_NAME})
|
||||
|
||||
target_include_directories( ${PROJECT_NAME}
|
||||
|
||||
Reference in New Issue
Block a user