mirror of
https://gitee.com/apaki/cmake_demo.git
synced 2025-07-03 07:46:53 +08:00
1.配置安装路径
2.启用测试 3.支持gdb以及配置gcc编译参数
This commit is contained in:
parent
08c9442df5
commit
c4709707c5
@ -10,6 +10,7 @@ set(CMAKE_INCLUDE_CURRENT_DIR ON)
|
||||
|
||||
# 2. 配置项目
|
||||
option(USE_DEMO "use demo application interface" ON)
|
||||
set(VERSION "1.0")
|
||||
|
||||
# 2. 配置文件
|
||||
configure_file(
|
||||
@ -38,3 +39,19 @@ add_executable(demo ${DIR_SRC})
|
||||
|
||||
# 1. 添加链接库
|
||||
target_link_libraries(demo list)
|
||||
|
||||
# 3. 配置安装路径
|
||||
set(CMAKE_INSTALL_PREFIX "./release")
|
||||
install(TARGETS demo DESTINATION bin)
|
||||
install (FILES "${PROJECT_BINARY_DIR}/config.h"
|
||||
DESTINATION include)
|
||||
|
||||
# 4. 启用测试
|
||||
enable_testing()
|
||||
# 测试程序是否成功运行
|
||||
add_test (NAME test_demo COMMAND demo 1 2 3 5 8)
|
||||
|
||||
# 5. 支持GDB
|
||||
set(CMAKE_BUILD_TYPE "Debug")
|
||||
set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -O0 -Wall -g -ggdb")
|
||||
set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O3 -Wall")
|
||||
|
@ -1 +1,2 @@
|
||||
#cmakedefine USE_DEMO
|
||||
#cmakedefine VERSION "@VERSION@"
|
14
main.c
14
main.c
@ -17,9 +17,19 @@ void list_demo(void)
|
||||
list_print(&list);
|
||||
}
|
||||
|
||||
|
||||
void main(int arg, char *argv[])
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
printf("----- Version = %s -----\n", VERSION);
|
||||
|
||||
if(argc != 1)
|
||||
{
|
||||
printf("# Program = [%s]\n", argv[0]);
|
||||
for(uint32_t i = 1; i < argc; i++)
|
||||
{
|
||||
printf("# Param[%d] = %s\n", i ,argv[i]);
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef USE_DEMO
|
||||
printf("list test!\n");
|
||||
struct list_t list;
|
||||
|
2
mk.bat
2
mk.bat
@ -2,3 +2,5 @@
|
||||
|
||||
cmake . -G "MinGW Makefiles" -B build
|
||||
make -C build
|
||||
make -C build install
|
||||
make -C build test
|
||||
|
@ -4,3 +4,7 @@ aux_source_directory(. DIR_LIB_SRC)
|
||||
|
||||
# 生成链接库
|
||||
add_library(list ${DIR_LIB_SRC})
|
||||
|
||||
# 配置安装路径
|
||||
install (TARGETS list DESTINATION bin)
|
||||
install (FILES list.h DESTINATION include)
|
||||
|
Loading…
Reference in New Issue
Block a user