Skip to content

Commit

Permalink
Cleans up build script, making 'csha1' easier to embed in other CMake…
Browse files Browse the repository at this point in the history
… projects.
  • Loading branch information
AndreLouisCaron committed Jan 21, 2012
1 parent 170c49d commit 254e738
Show file tree
Hide file tree
Showing 7 changed files with 448 additions and 184 deletions.
53 changes: 46 additions & 7 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,58 @@ cmake_minimum_required(VERSION 2.8)

project(httpxx)

# Compile API documentation from source code.
function(add_api_documentation target)
if(DOXYGEN_EXECUTABLE)
add_custom_target(
${target}
COMMAND
${DOXYGEN_EXECUTABLE}
WORKING_DIRECTORY
${CMAKE_CURRENT_BINARY_DIR}
COMMENT
"Compiling documentation."
VERBATIM
)
endif()
endfunction()

include_directories(${CMAKE_CURRENT_SOURCE_DIR}/libs/http-parser)

file(GLOB ${PROJECT_NAME}_HEADERS code/*.hpp)
file(GLOB ${PROJECT_NAME}_SOURCES code/*.cpp)
add_library(${PROJECT_NAME} STATIC
${${PROJECT_NAME}_SOURCES}
${${PROJECT_NAME}_HEADERS}
${CMAKE_CURRENT_SOURCE_DIR}/libs/http-parser/http_parser.h
${CMAKE_CURRENT_SOURCE_DIR}/libs/http-parser/http_parser.c)
# http-parser does not provide a CMake build script.
set(http_parser_DIR
${CMAKE_SOURCE_DIR}/libs/http-parser
)
set(http-parser_headers ${http_parser_DIR}/http_parser.h)
set(http-parser_sources ${http_parser_DIR}/http_parser.c)
if(MSVC)
# MSVC does not support C99, but its C++ compiler is
# compatible with the http-parser library's code.
set_source_files_properties(
${http-parser_headers}
${http-parser_sources}
PROPERTIES LANGUAGE CXX
)
endif()
add_library(http-parser
STATIC
${http-parser_headers}
${http-parser_sources}
)

# Build the primary target.
add_subdirectory(code)

# When building in standalone mode, build demo projects.
if(${PROJECT_NAME} STREQUAL ${CMAKE_PROJECT_NAME})

# Build API documentation.
find_package(Doxygen QUIET)
configure_file(
${CMAKE_SOURCE_DIR}/help/Doxyfile
${CMAKE_BINARY_DIR}/Doxyfile @ONLY)
add_api_documentation(doc)

# Resolve include directives as if installed on the system.
include_directories(${CMAKE_CURRENT_SOURCE_DIR}/code)

Expand Down
24 changes: 24 additions & 0 deletions code/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# httpxx library.

set(headers
Error.hpp
Flags.hpp
Message.hpp
Method.hpp
Request.hpp
Response.hpp
)
set(sources
Error.cpp
Flags.cpp
Message.cpp
Method.cpp
Request.cpp
Response.cpp
)
add_library(httpxx
STATIC
${sources}
${headers}
)
add_dependencies(httpxx http-parser)
18 changes: 18 additions & 0 deletions code/http.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
#ifndef _http_hpp__
#define _http_hpp__

// Copyright(c) Andre Caron <andre.l.caron@gmail.com>, 2011
//
// This document is covered by the an Open Source Initiative approved license. A
// copy of the license should have been provided alongside this software package
// (see "LICENSE.txt"). If not, terms of the license are available online at
// "http://www.opensource.org/licenses/mit".

#include "Error.hpp"
#include "Flags.hpp"
#include "Message.hpp"
#include "Method.hpp"
#include "Request.hpp"
#include "Response.hpp"

#endif /* _http_hpp__ */
176 changes: 0 additions & 176 deletions demo.vcproj

This file was deleted.

Loading

0 comments on commit 254e738

Please sign in to comment.