initial commit - linking static lib to executable
This commit is contained in:
7
cplusplus/cmake_ys/executable_staticlib/A/CMakeLists.txt
Normal file
7
cplusplus/cmake_ys/executable_staticlib/A/CMakeLists.txt
Normal file
@@ -0,0 +1,7 @@
|
|||||||
|
add_subdirectory(TestA)
|
||||||
|
add_subdirectory(LibA)
|
||||||
|
|
||||||
|
target_link_libraries(TestA
|
||||||
|
PRIVATE
|
||||||
|
LibA
|
||||||
|
)
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
|
||||||
|
|
||||||
|
add_library(LibA)
|
||||||
|
target_sources(LibA
|
||||||
|
PRIVATE
|
||||||
|
func1.cxx
|
||||||
|
|
||||||
|
PUBLIC
|
||||||
|
FILE_SET HEADERS
|
||||||
|
FILES
|
||||||
|
func1.h
|
||||||
|
|
||||||
|
|
||||||
|
)
|
||||||
|
|
||||||
6
cplusplus/cmake_ys/executable_staticlib/A/LibA/func1.cxx
Normal file
6
cplusplus/cmake_ys/executable_staticlib/A/LibA/func1.cxx
Normal file
@@ -0,0 +1,6 @@
|
|||||||
|
namespace LibA {
|
||||||
|
double sqrt(double x)
|
||||||
|
{
|
||||||
|
return -42;
|
||||||
|
}
|
||||||
|
}
|
||||||
3
cplusplus/cmake_ys/executable_staticlib/A/LibA/func1.h
Normal file
3
cplusplus/cmake_ys/executable_staticlib/A/LibA/func1.h
Normal file
@@ -0,0 +1,3 @@
|
|||||||
|
namespace LibA {
|
||||||
|
double sqrt(double x);
|
||||||
|
}
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
|
||||||
|
add_executable(TestA)
|
||||||
|
|
||||||
|
target_sources(TestA
|
||||||
|
PRIVATE
|
||||||
|
testA.cxx
|
||||||
|
)
|
||||||
|
|
||||||
|
target_link_libraries(TestA
|
||||||
|
PRIVATE
|
||||||
|
LibA
|
||||||
|
)
|
||||||
|
|
||||||
@@ -0,0 +1,9 @@
|
|||||||
|
#include "iostream"
|
||||||
|
#include "func1.h"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
std::cout<<"hello world"<<std::endl<<LibA::sqrt(5);
|
||||||
|
|
||||||
|
}
|
||||||
2
cplusplus/cmake_ys/executable_staticlib/B/CMakeLists.txt
Normal file
2
cplusplus/cmake_ys/executable_staticlib/B/CMakeLists.txt
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
add_subdirectory(TestB)
|
||||||
|
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
|
||||||
|
add_executable(TestB)
|
||||||
|
target_sources(TestB
|
||||||
|
PRIVATE
|
||||||
|
testB.cxx
|
||||||
|
)
|
||||||
@@ -0,0 +1,8 @@
|
|||||||
|
#include "iostream"
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
std::cout<<"hello world"<<std::endl;
|
||||||
|
|
||||||
|
}
|
||||||
5
cplusplus/cmake_ys/executable_staticlib/CMakeLists.txt
Normal file
5
cplusplus/cmake_ys/executable_staticlib/CMakeLists.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.23)
|
||||||
|
project(learning2)
|
||||||
|
|
||||||
|
add_subdirectory(A)
|
||||||
|
add_subdirectory(B)
|
||||||
Reference in New Issue
Block a user