cmake_minimum_required(VERSION 2.8.0)
project(h2o_app)
find_library(H2O_LIB h2o-evloop)
find_library(MUSTACHE_C_LIB mustache_c)
find_library(YAJL_LIB yajl)
find_path(H2O_INCLUDE h2o.h)
find_path(MUSTACHE_C_INCLUDE mustache.h)
find_path(YAJL_INCLUDE yajl/yajl_gen.h)
set(COMMON_OPTIONS -flto -pthread)
add_compile_options(-std=gnu11 -pedantic -Wall -Wextra ${COMMON_OPTIONS})
set(CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -D_FORTIFY_SOURCE=2")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -O3")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELWITHDEBINFO} -O3")
add_definitions(-DH2O_USE_LIBUV=0)
include_directories(src ${H2O_INCLUDE} ${MUSTACHE_C_INCLUDE} ${YAJL_INCLUDE})
file(GLOB SOURCES "src/*.c")
add_executable(${PROJECT_NAME} ${SOURCES})
target_link_libraries(${PROJECT_NAME} ${COMMON_OPTIONS})
target_link_libraries(${PROJECT_NAME} ${H2O_LIB} ssl crypto numa pq z ${MUSTACHE_C_LIB} ${YAJL_LIB})
install(TARGETS ${PROJECT_NAME} RUNTIME DESTINATION bin)
file(GLOB TEMPLATES "template/*")
install(FILES ${TEMPLATES} DESTINATION share/${PROJECT_NAME}/template)
