forked from Azariashvili/Development-Template-2020-2021
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add template of program with static library
- Loading branch information
Showing
13 changed files
with
29,753 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
cmake_minimum_required(VERSION 3.6 FATAL_ERROR) | ||
|
||
project(samples) | ||
|
||
include(cmake/function.cmake) | ||
|
||
add_subdirectory(function_lib) | ||
add_subdirectory(main) | ||
|
||
option(BTEST "build test?" OFF) | ||
|
||
if(BTEST) | ||
add_subdirectory(gtest) | ||
add_subdirectory(test) | ||
endif() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
function(create_project_lib TARGET ) | ||
file(GLOB TARGET_SRC "*.c*") | ||
file(GLOB TARGET_HD "*.h*") | ||
add_library(${TARGET} STATIC ${TARGET_SRC} ${TARGET_HD}) | ||
|
||
get_property ( INCLUDE_DIRS GLOBAL PROPERTY INC_DIR) | ||
list(APPEND INCLUDE_DIRS ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set_property ( GLOBAL PROPERTY INC_DIR ${INCLUDE_DIRS}) | ||
|
||
get_property ( LIB_LIST GLOBAL PROPERTY LIBS_P) | ||
list(APPEND LIB_LIST ${TARGET}) | ||
set_property ( GLOBAL PROPERTY LIBS_P ${LIB_LIST}) | ||
|
||
endfunction() | ||
|
||
function(create_executable_project TARGET) | ||
file(GLOB TARGET_SRC "*.c*") | ||
file(GLOB TARGET_HD "*.h*") | ||
add_executable(${TARGET} ${TARGET_SRC} ${TARGET_HD}) | ||
|
||
get_property ( INCLUDE_DIRS GLOBAL PROPERTY INC_DIR) | ||
target_include_directories(${TARGET} PUBLIC ${INCLUDE_DIRS}) | ||
|
||
get_property ( LIB_LIST GLOBAL PROPERTY LIBS_P) | ||
target_link_libraries(${TARGET} ${LIB_LIST}) | ||
|
||
endfunction() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
create_project_lib(mylibrary) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
int add(int a, int b) { | ||
return a + b; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#ifndef INCLUDE_ADD_H_ | ||
#define INCLUDE_ADD_H_ | ||
|
||
int add(int a, int b); | ||
|
||
#endif // INCLUDE_ADD_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
set(target "gtest") | ||
create_project_lib(${target}) | ||
|
||
#if((${CMAKE_CXX_COMPILER_ID} MATCHES "GNU" OR | ||
# ${CMAKE_CXX_COMPILER_ID} MATCHES "Clang") AND | ||
# (${CMAKE_SYSTEM_NAME} MATCHES "Linux")) | ||
# set(pthread "-pthread") | ||
#endif() | ||
#target_link_libraries(${target} ${pthread}) | ||
|
||
find_package(Threads) | ||
if(THREADS_HAVE_PTHREAD_ARG) | ||
target_compile_options(${target} PUBLIC "-pthread") | ||
endif() | ||
if(CMAKE_THREAD_LIBS_INIT) | ||
target_link_libraries(${target} "${CMAKE_THREAD_LIBS_INIT}") | ||
endif() | ||
|
Oops, something went wrong.