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);
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user