cmake_minimum_required(VERSION 3.2.1 FATAL_ERROR)
project("soxy")
add_definitions(-std=c99)
include_directories(soxy)
# Includes
include(ExternalProject)
ExternalProject_Add(
LibUV
GIT_REPOSITORY "https://github.com/libuv/libuv.git"
GIT_TAG "v1.4.2"
CONFIGURE_COMMAND sh <SOURCE_DIR>/autogen.sh && ./configure --prefix=${CMAKE_BINARY_DIR}/libuv/src/LibUV
PATCH_COMMAND ""
BUILD_COMMAND "make"
BUILD_IN_SOURCE 1
PREFIX ${CMAKE_CURRENT_BINARY_DIR}/libuv
)
ExternalProject_Get_Property(LibUV install_dir)
add_library(libuv STATIC IMPORTED)
set_property(TARGET libuv PROPERTY IMPORTED_LOCATION ${install_dir}/src/LibUV/lib/libuv.a)
set( SOXY_BIN src/soxy.c )
set(SOXY_SRC
src/file_utils.c
src/http_parser.c
src/http_request.c
src/path_utils.c
src/string_utils.c
)
add_executable(soxy src/soxy.c ${SOXY_SRC})
add_dependencies(soxy LibUV)
include_directories(${install_dir}/src/LibUV/include)
target_link_libraries(soxy libuv)
这会创建一个没有错误的Makefile,并允许我运行make。
但是soxy.c包含int main函数{},但是当我执行./soxy
时,它还没有被运行。