First commit
This commit is contained in:
commit
6e8e09149f
3
.gitignore
vendored
Normal file
3
.gitignore
vendored
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
build/*
|
||||||
|
build
|
||||||
|
lib/myDynamicLibrary .gitignore
|
0
.gitmodules
vendored
Normal file
0
.gitmodules
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
5
.vscode/settings.json
vendored
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
{
|
||||||
|
"files.associations": {
|
||||||
|
"iostream": "cpp"
|
||||||
|
}
|
||||||
|
}
|
74
CMakeLists.txt
Normal file
74
CMakeLists.txt
Normal file
@ -0,0 +1,74 @@
|
|||||||
|
# Minimum required version of CMake
|
||||||
|
cmake_minimum_required(VERSION 3.20)
|
||||||
|
|
||||||
|
# Set the project name, version, homepage, and description
|
||||||
|
project(main VERSION 1.0.0
|
||||||
|
HOMEPAGE_URL "https://git.noorlander.info/E.Noorlander/CMake_SDL_CPP.git"
|
||||||
|
DESCRIPTION "Demo embedded Linux C++ project"
|
||||||
|
LANGUAGES CXX) # Use CXX for C++ projects
|
||||||
|
|
||||||
|
# Set a custom application name and definitions
|
||||||
|
set(BIN_NAME "test")
|
||||||
|
add_compile_definitions(APP_NAME="${BIN_NAME}")
|
||||||
|
|
||||||
|
# Set 1 to compile static (Standalone) or 0 to use shared libraries
|
||||||
|
set(BIN_STATIC 1)
|
||||||
|
|
||||||
|
# Set binary suffix based on the operating system
|
||||||
|
if(CMAKE_SYSTEM_NAME STREQUAL "Windows")
|
||||||
|
set(BIN_SUFFIX ".exe")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Darwin")
|
||||||
|
set(BIN_SUFFIX ".app")
|
||||||
|
elseif(CMAKE_SYSTEM_NAME STREQUAL "Linux")
|
||||||
|
set(BIN_SUFFIX ".elf")
|
||||||
|
else()
|
||||||
|
set(BIN_SUFFIX ".bin")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# For Windows-specific configurations
|
||||||
|
if(MSVC)
|
||||||
|
# Uncomment to specify the C++ standard explicitly
|
||||||
|
add_compile_options(/std:c++11)
|
||||||
|
set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS TRUE)
|
||||||
|
set(BUILD_SHARED_LIBS TRUE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# List of subprojects to include (e.g., external libraries or modules)
|
||||||
|
set(SubProjects
|
||||||
|
myDynamicLibrary # Example subproject, replace with actual subprojects
|
||||||
|
)
|
||||||
|
|
||||||
|
# Create the main executable, specifying the source file
|
||||||
|
add_executable(${PROJECT_NAME} ${CMAKE_CURRENT_SOURCE_DIR}/src/main.cpp)
|
||||||
|
|
||||||
|
# Set target properties like output name and suffix
|
||||||
|
set_target_properties(${PROJECT_NAME}
|
||||||
|
PROPERTIES
|
||||||
|
OUTPUT_NAME ${BIN_NAME}
|
||||||
|
SUFFIX ${BIN_SUFFIX}
|
||||||
|
)
|
||||||
|
|
||||||
|
# Loop over the subprojects and link them to the main executable
|
||||||
|
foreach(Project IN LISTS SubProjects)
|
||||||
|
# Check if the target for this subproject has been added already
|
||||||
|
if(NOT TARGET ${Project})
|
||||||
|
# Add the subproject's directory to the build (if not already added)
|
||||||
|
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/lib/${Project})
|
||||||
|
endif()
|
||||||
|
|
||||||
|
# Link the subproject to the main project executable
|
||||||
|
if(BIN_STATIC)
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${Project} -static)
|
||||||
|
else()
|
||||||
|
target_link_libraries(${PROJECT_NAME} PRIVATE ${Project})
|
||||||
|
endif()
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
# Add processor count and parallel build support
|
||||||
|
include(ProcessorCount)
|
||||||
|
ProcessorCount(N)
|
||||||
|
if(NOT N EQUAL 0)
|
||||||
|
set(CTEST_BUILD_FLAGS -j${N})
|
||||||
|
set(ctest_test_args ${PROJECT_NAME} PARALLEL_LEVEL ${N})
|
||||||
|
endif()
|
||||||
|
|
3
README.md
Normal file
3
README.md
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
# CMake C++ Template with SDL libary Project
|
||||||
|
|
||||||
|
Under construction
|
1
clean.sh
Executable file
1
clean.sh
Executable file
@ -0,0 +1 @@
|
|||||||
|
rm -rf CMakeCache.txt CMakeFiles/ cmake_install.cmake Makefile compiler compiler/bin bin build
|
4
install.sh
Executable file
4
install.sh
Executable file
@ -0,0 +1,4 @@
|
|||||||
|
mkdir build
|
||||||
|
cd build
|
||||||
|
cmake .. --fresh
|
||||||
|
make
|
3
lib/myDynamicLibrary/CMakeLists.txt
Normal file
3
lib/myDynamicLibrary/CMakeLists.txt
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
add_library(myDynamicLibrary myDynamicLibrary.cpp)
|
||||||
|
|
||||||
|
target_include_directories(myDynamicLibrary INTERFACE ${CMAKE_CURRENT_SOURCE_DIR})
|
21
lib/myDynamicLibrary/myDynamicLibrary.cpp
Normal file
21
lib/myDynamicLibrary/myDynamicLibrary.cpp
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
// myDynamicLibrary.cpp
|
||||||
|
|
||||||
|
#include "myDynamicLibrary.h"
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
void myDynamicLibrary::sayHelloDynamic()
|
||||||
|
{
|
||||||
|
cout << "Hello from the dynamic library!\n";
|
||||||
|
cout << "You have given two numbers a ";
|
||||||
|
cout << myDynamicLibrary::a << " and number b ";
|
||||||
|
cout << myDynamicLibrary::b << "\n";
|
||||||
|
}
|
||||||
|
|
||||||
|
int myDynamicLibrary::multiply(){
|
||||||
|
return myDynamicLibrary::a * myDynamicLibrary::b;
|
||||||
|
}
|
||||||
|
|
||||||
|
int myDynamicLibrary::devide(){
|
||||||
|
return myDynamicLibrary::a / myDynamicLibrary::b;
|
||||||
|
}
|
17
lib/myDynamicLibrary/myDynamicLibrary.h
Normal file
17
lib/myDynamicLibrary/myDynamicLibrary.h
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
// myDynamicLibrary.h
|
||||||
|
|
||||||
|
#ifndef MYDYNAMICLIBRARY_H
|
||||||
|
#define MYDYNAMICLIBRARY_H
|
||||||
|
|
||||||
|
class myDynamicLibrary{
|
||||||
|
public:
|
||||||
|
int a;
|
||||||
|
int b;
|
||||||
|
|
||||||
|
void sayHelloDynamic();
|
||||||
|
int multiply();
|
||||||
|
int devide();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
#endif // MYDYNAMICLIBRARY_H
|
20
src/main.cpp
Normal file
20
src/main.cpp
Normal file
@ -0,0 +1,20 @@
|
|||||||
|
// main.cpp
|
||||||
|
#include "../lib/myDynamicLibrary/myDynamicLibrary.h"
|
||||||
|
#include <iostream>
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
myDynamicLibrary myObj;
|
||||||
|
|
||||||
|
int main()
|
||||||
|
{
|
||||||
|
|
||||||
|
myObj.a = 10;
|
||||||
|
myObj.b = 5;
|
||||||
|
|
||||||
|
myObj.sayHelloDynamic();
|
||||||
|
|
||||||
|
cout << "Addition: " << myObj.multiply() << endl;
|
||||||
|
cout << "Subtraction: " << myObj.devide() << endl;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user