mirror of
https://github.com/ttroy50/cmake-examples.git
synced 2025-12-18 20:24:35 +03:00
add initial folder structure and the first basic examples
This commit is contained in:
36
01-basic/D-shared-library/CMakeLists.txt
Normal file
36
01-basic/D-shared-library/CMakeLists.txt
Normal file
@@ -0,0 +1,36 @@
|
||||
cmake_minimum_required(VERSION 2.6)
|
||||
|
||||
project(hello_library)
|
||||
|
||||
include_directories(
|
||||
${PROJECT_SOURCE_DIR}/inc
|
||||
)
|
||||
|
||||
############################################################
|
||||
# Create a library
|
||||
############################################################
|
||||
|
||||
# Source files to be used in the library
|
||||
set(library_SOURCES
|
||||
src/Hello.cpp
|
||||
)
|
||||
|
||||
#Generate the shared library from the library sources
|
||||
add_library(hello_library SHARED ${library_SOURCES})
|
||||
|
||||
############################################################
|
||||
# Create an executable
|
||||
############################################################
|
||||
|
||||
# Source fles for the binary
|
||||
set(binary_SOURCES
|
||||
src/main.cpp
|
||||
)
|
||||
|
||||
# Add an executable with the above sources
|
||||
add_executable(hello_binary ${binary_SOURCES})
|
||||
|
||||
# link the new hello_library target with the hello_binary target
|
||||
target_link_libraries( hello_binary
|
||||
hello_library
|
||||
)
|
||||
0
01-basic/D-shared-library/README.md
Normal file
0
01-basic/D-shared-library/README.md
Normal file
10
01-basic/D-shared-library/inc/Hello.h
Normal file
10
01-basic/D-shared-library/inc/Hello.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef __HELLO_H__
|
||||
#define __HELLO_H__
|
||||
|
||||
class Hello
|
||||
{
|
||||
public:
|
||||
void print();
|
||||
};
|
||||
|
||||
#endif
|
||||
8
01-basic/D-shared-library/src/Hello.cpp
Normal file
8
01-basic/D-shared-library/src/Hello.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include <iostream>
|
||||
|
||||
#include "Hello.h"
|
||||
|
||||
void Hello::print()
|
||||
{
|
||||
std::cout << "Hello Shared Library!" << std::endl;
|
||||
}
|
||||
8
01-basic/D-shared-library/src/main.cpp
Normal file
8
01-basic/D-shared-library/src/main.cpp
Normal file
@@ -0,0 +1,8 @@
|
||||
#include "Hello.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
Hello hi;
|
||||
hi.print();
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user