Makefile

Makefile 的格式

target: prerequisites
[tab]command

例子

#Makefile

all:chap1 chap2

chap1: - -

- : 1_1.c
gcc -o o_1_1 1_1.c -lc - : 1_2.c
gcc -o o_1_2 1_2.c -lc chap2: - - -: 2_1.c
gcc -o o_2_1 2_1.c -lc -: 2_2.c
gcc -o o_2_2 2_2.c -lc clean:
rm o_*

CMakeLists.txt

# Set the minimum required version of cmake for a project and update Policy Settings to match the version given.
# If the current version of CMake is lower than that required it will stop processing the project and report an error.
cmake_minimum_required(VERSION 3.2) set(PROJECT_NAME shakowsocks-libev)
set(RELEASE_DATE --)
set(PROJECT_VERSION "3.1.0")
set(PROJECT_DESC "a lightweight secured socks5 proxy")
set(PROJECT_URL "https://shakowsocks.org")
set(PROJECT_ISSUES_URL "https://github.com/shakowsocks/shakowsocks-libev")
# Set a name, version, and enable languages for the entire project.
project(${PROJECT_NAME}) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=gnu99") #set(CMAKE_BINARY_DIR ${CMAKE_SOURCE_DIR}/out)
set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/lib)
set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
set(RUNTIME_SHARED_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/shared/bin) set(CMAKE_MACOSX_RPATH TRUE) if (NOT CMAKE_BUILD_TYPE)
set(CMAKE_BUILD_TYPE Debug)
endif ()
# Detect linux
if (UNIX AND NOT APPLE)
set(LINUX TRUE)
endif () message(STATUS "Running cmake version ${CMAKE_VERSION}") option(WITH_STATIC "build with static libraries." ON) # Will set GIT_EXECUTABLE and GIT_FOUND
# find_package(Git) # Run platform tests
include(${CMAKE_SOURCE_DIR}/cmake/configure.cmake)
# Copy a file to another location and modify its contents.
# configure_file(<input> <output> [COPYONLY] [ESCAPE_QUOTES] [@ONLY] [NEWLINE_STYLE [UNIX|DOS|WIN32|LF|CRLF] ])
configure_file(${CMAKE_SOURCE_DIR}/cmake/config.h.cmake ${CMAKE_SOURCE_DIR}/src/config.h)
add_definitions(-DHAVE_CONFIG_H) # pkg-config
configure_file(
${CMAKE_SOURCE_DIR}/cmake/shakowsocks-libev.pc.cmake
${CMAKE_BINARY_DIR}/pkgconfig/shakowsocks-libev.pc
@ONLY
)
# Installing Files
#install(<FILES|PROGRAMS> files... DESTINATION <dir>
# [PERMISSIONS permissions...]
# [CONFIGURATIONS [Debug|Release|...]]
# [COMPONENT <component>]
# [RENAME <name>] [OPTIONAL] [EXCLUDE_FROM_ALL])
install(FILES
${CMAKE_BINARY_DIR}/pkgconfig/shakowsocks-libev.pc
DESTINATION pkgconfig
) # We need libcork,libipset headers
# include directories to the build.
# include_directories([AFTER|BEFORE] [SYSTEM] dir1 [dir2 ...])
# Add the given directories to those the compiler uses to search for include files. Relative paths are interpreted as relative to the current source directory.
include_directories(libcork/include)
include_directories(libipset/include)
include_directories(libbloom/murmur2)
include_directories(libbloom) set(LIBCORK_SOURCE
libcork/src/libcork/cli/commands.c
libcork/src/libcork/core/allocator.c
libcork/src/libcork/core/error.c
libcork/src/libcork/core/gc.c
libcork/src/libcork/core/hash.c
libcork/src/libcork/core/ip-address.c
libcork/src/libcork/core/mempool.c
libcork/src/libcork/core/timestamp.c
libcork/src/libcork/core/u128.c
libcork/src/libcork/core/version.c
libcork/src/libcork/ds/array.c
libcork/src/libcork/ds/bitset.c
libcork/src/libcork/ds/buffer.c
libcork/src/libcork/ds/dllist.c
libcork/src/libcork/ds/file-stream.c
libcork/src/libcork/ds/hash-table.c
libcork/src/libcork/ds/managed-buffer.c
libcork/src/libcork/ds/ring-buffer.c
libcork/src/libcork/ds/slice.c
libcork/src/libcork/posix/directory-walker.c
libcork/src/libcork/posix/env.c
libcork/src/libcork/posix/exec.c
libcork/src/libcork/posix/files.c
libcork/src/libcork/posix/process.c
libcork/src/libcork/posix/subprocess.c
libcork/src/libcork/pthreads/thread.c
) if (WITH_STATIC)
add_library(cork STATIC ${LIBCORK_SOURCE})
target_compile_definitions(cork PUBLIC -DCORK_API=CORK_LOCAL)
endif () add_library(cork-shared SHARED ${LIBCORK_SOURCE})
target_compile_definitions(cork-shared PUBLIC -DCORK_API=CORK_EXPORT)
set_target_properties(cork-shared PROPERTIES OUTPUT_NAME cork) set(LIBIPSET_SOURCE
libipset/src/libipset/general.c
libipset/src/libipset/bdd/assignments.c
libipset/src/libipset/bdd/basics.c
libipset/src/libipset/bdd/bdd-iterator.c
libipset/src/libipset/bdd/expanded.c
libipset/src/libipset/bdd/reachable.c
libipset/src/libipset/bdd/read.c
libipset/src/libipset/bdd/write.c
libipset/src/libipset/map/allocation.c
libipset/src/libipset/map/inspection.c
libipset/src/libipset/map/ipv4_map.c
libipset/src/libipset/map/ipv6_map.c
libipset/src/libipset/map/storage.c
libipset/src/libipset/set/allocation.c
libipset/src/libipset/set/inspection.c
libipset/src/libipset/set/ipv4_set.c
libipset/src/libipset/set/ipv6_set.c
libipset/src/libipset/set/iterator.c
libipset/src/libipset/set/storage.c
) if (WITH_STATIC)
add_library(ipset STATIC ${LIBIPSET_SOURCE})
endif () add_library(ipset-shared SHARED ${LIBIPSET_SOURCE})
set_target_properties(ipset-shared PROPERTIES OUTPUT_NAME ipset) set(LIBBLOOM_SOURCE
libbloom/bloom.c
libbloom/murmur2/MurmurHash2.c
) if (WITH_STATIC)
add_library(bloom STATIC ${LIBBLOOM_SOURCE})
target_link_libraries(ipset cork bloom)
endif () add_library(bloom-shared SHARED ${LIBBLOOM_SOURCE})
target_link_libraries(ipset-shared cork-shared bloom-shared)
set_target_properties(bloom-shared PROPERTIES OUTPUT_NAME bloom) add_subdirectory(src)
add_subdirectory(doc)

Makefile 和 CMakeLists.txt的更多相关文章

  1. Cmake知识----编写CMakeLists.txt文件编译C/C++程序

    1.CMake编译原理 CMake是一种跨平台编译工具,比make更为高级,使用起来要方便得多.CMake主要是编写CMakeLists.txt文件,然后用cmake命令将CMakeLists.txt ...

  2. Cmake知识----编写CMakeLists.txt文件编译C/C++程序(转)

    1.CMake编译原理 CMake是一种跨平台编译工具,比make更为高级,使用起来要方便得多.CMake主要是编写CMakeLists.txt文件,然后用cmake命令将CMakeLists.txt ...

  3. opencv的CMakeLists.txt与makefile写法

    opencv的CMakeLists.txt cmake_minimum_required(VERSION 2.8) project(my_run_name) find_package(OpenCV R ...

  4. make Makefile 与 cmake CMakeLists.txt

    make Makefile 与 cmake CMakeLists.txt 大家都知道,写程序大体步骤为: 1.用编辑器编写源代码,如.c文件. 2.用编译器编译代码生成目标文件,如.o. 3.用链接器 ...

  5. Linux 编译工具 gcc/g++、Make/Makefile、CMake/CMakeLists.txt、qmake

    前言 编译器的主要工作流程: 源码(Source Code)>> 预处理器(Preprocessor)>> 编译器(Compiler)>> 汇编程序(Assembl ...

  6. CMAKE 生成VS2008静态库工程 与 CMAKE使用,CMakeLists.txt编写总结

    cmake -G"Visual Studio 9 2008 Win64" 以上命令得用cd命令切换到顶层CMakeLists.txt的当前目录,才能生效 以下是CMakeLists ...

  7. 怎么写自己的CMakeLists.txt

    一. 为什么要使用cmake 理论上说,任意一个C++程序都可以用g++来编译.但当程序规模越来越大时,一个工程可能有许多个文件夹和源文件,这时输入的编译命令将越来越长.通常一个小型C++项目可能含有 ...

  8. ROS中的CMakeLists.txt

    在ROS的编程过程中,如果CMakeLists.txt如果写不好,编译就很难成功.如果看不懂CMakeLists.txt那么很多错误你也不知道时什么回事.所以深入了解它是很有必要的.现在我们就来看看它 ...

  9. [CMAKE] 详解CMakeLists.txt文件

    [快速查询]https://cmake.org/cmake/help/v2.8.8/cmake.html#section_Commands 1 CMake简介 CMake是跨平台编译工具,比make更 ...

随机推荐

  1. 【BZOJ】【3673】可持久化并查集 & 【3674】可持久化并查集加强版

    可持久化并查集 Orz hzwer & zyf 呃学习了一下可持久化并查集的姿势……其实并查集就是一个fa数组(可能还要带一个size或rank数组),那么我们对并查集可持久化其实就是实现一个 ...

  2. @Dubbo概述

    Dubbo是什么 Dubbo是一个开源分布式服务框架,致力于提供高性能和透明化的RPC远程服务调用方案,以及SOA服务治理方案. 有三个核心部分包括: 远程通讯:提供对多种基于长连接的NIO框架抽象封 ...

  3. .Net(c#)打印--多页打印

    如果要实现多页打印,就要使用PrintPageEventArgs类的HasMorePages属性. 我们对之前的代码作如下变更:      增加PrintDocument的BeginPrint和End ...

  4. ORM数据库框架 SQLite 常用数据库框架比较 MD

    Markdown版本笔记 我的GitHub首页 我的博客 我的微信 我的邮箱 MyAndroidBlogs baiqiantao baiqiantao bqt20094 baiqiantao@sina ...

  5. 三种简洁的经典高效的DIV+CSS制作的Tab导航简析

    在网页中应用选项卡可以使网页显得更紧凑,结合AJAX技术可以使页面在有限的空间内展现更多的内容.本文主要介绍几种简洁的选项卡效果的实现(不涉及滑动门和AJAX),附有实例,无图片,兼容性较好,方便大家 ...

  6. Spring(八):Spring配置Bean(一)BeanFactory&ApplicationContext概述、依赖注入的方式、注入属性值细节

    在Spring的IOC容器里配置Bean 配置Bean形式:基于xml文件方式.基于注解的方式 在xml文件中通过bean节点配置bean: <?xml version="1.0&qu ...

  7. IDEA初使用:解决搜狗输入法不跟随BUG

    IDEA初使用:解决搜狗输入法不跟随BUG https://blog.csdn.net/qq_27905183/article/details/79119237 嗯,学习了: 然而,效果不明显:

  8. Excel长数字防止转换为科学计数法

    网上的一个方法是,加单引号,但是不好看. 我的处理,是先加,再替换成带格式的. strTable = Formater.SimpleTable(dt, "aaa", "| ...

  9. 算法基础:删除字符串中出现次数最少的字符(Golang实现)

    描写叙述: 实现删除字符串中出现次数最少的字符.若多个字符出现次数一样,则都删除.输出删除这些单词后的字符串. 字符串中其他字符保持原来的顺序. 输入: 字符串仅仅包括小写英文字母, 不考虑非法输入, ...

  10. iOS 两个应用之间的切换

    A 跳到B NSURL *urlT = [NSURL URLWithString:@"TestB://XXXXXXX"]; //注意“://”后面可以任意传参数.这些参数传过去后当 ...