-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
cmake: introduce cmake as alternative build system
see #27 Signed-off-by: Alexander Dahl <post@lespocky.de>
- Loading branch information
Showing
5 changed files
with
112 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ libcgi.so | |
autom4te.cache | ||
configure | ||
src/config.h | ||
*swp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# | ||
# Copyright 2013,2016 Alexander Dahl <post@lespocky.de> | ||
# | ||
cmake_minimum_required(VERSION 2.8.8) | ||
|
||
project(cgi) | ||
string(TOUPPER ${PROJECT_NAME} PROJECT_NAME_UC) | ||
string(TOLOWER ${PROJECT_NAME} PROJECT_NAME_LC) | ||
set(LIBPREFIX ${PROJECT_NAME}) | ||
set(LIBPREFIX_LC ${PROJECT_NAME_LC}) | ||
set(LIBPREFIX_UC ${PROJECT_NAME_UC}) | ||
|
||
set(PACKAGE_MAJOR_VERSION "1") | ||
set(PACKAGE_MINOR_VERSION "0") | ||
set(PACKAGE_BUILD_VERSION "0") | ||
set(PACKAGE_VERSION "${PACKAGE_MAJOR_VERSION}.${PACKAGE_MINOR_VERSION}.${PACKAGE_BUILD_VERSION}") | ||
|
||
# includes | ||
include(CMakePackageConfigHelpers) # cmake 2.8.8 | ||
include(FeatureSummary) | ||
include(GNUInstallDirs) # cmake 2.8.5 | ||
|
||
# subdirectories | ||
add_subdirectory("src") | ||
|
||
# cmake package stuff | ||
configure_package_config_file(${PROJECT_NAME_LC}-config.cmake.in | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LC}-config.cmake" | ||
INSTALL_DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" | ||
PATH_VARS CMAKE_INSTALL_INCLUDEDIR | ||
NO_CHECK_REQUIRED_COMPONENTS_MACRO | ||
) | ||
write_basic_package_version_file( | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LC}-config-version.cmake" | ||
VERSION ${PACKAGE_VERSION} | ||
COMPATIBILITY AnyNewerVersion | ||
) | ||
install(FILES | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LC}-config.cmake" | ||
"${CMAKE_CURRENT_BINARY_DIR}/${PROJECT_NAME_LC}-config-version.cmake" | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" | ||
) | ||
|
||
# feature summary | ||
message(STATUS "CMAKE_BUILD_TYPE: ${CMAKE_BUILD_TYPE}") | ||
feature_summary(WHAT ALL) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# | ||
# Copyright 2013 Alexander Dahl <post@lespocky.de> | ||
# | ||
|
||
# paths | ||
@PACKAGE_INIT@ | ||
set_and_check(CGI_INCLUDE_DIRS "@PACKAGE_CMAKE_INSTALL_INCLUDEDIR@/@PROJECT_NAME@") | ||
|
||
# targets | ||
get_filename_component(_dir "${CMAKE_CURRENT_LIST_FILE}" PATH) | ||
if(NOT TARGET @PROJECT_NAME@-shared) | ||
include("${_dir}/@PROJECT_NAME@-targets.cmake") | ||
endif(NOT TARGET @PROJECT_NAME@-shared) | ||
set(CGI_LIBRARIES @PROJECT_NAME@-shared) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
# | ||
# Copyright 2013,2016 Alexander Dahl <post@lespocky.de> | ||
# | ||
configure_file( | ||
"${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake.in" | ||
"${CMAKE_CURRENT_BINARY_DIR}/config.h" | ||
) | ||
|
||
include_directories( | ||
"${CMAKE_CURRENT_BINARY_DIR}" | ||
) | ||
|
||
set(CGI_SRC | ||
base64.c | ||
cgi.c | ||
cookie.c | ||
error.c | ||
general.c | ||
list.c | ||
# md5.c | ||
session.c | ||
string.c | ||
) | ||
|
||
# create binary | ||
add_library(${PROJECT_NAME}-shared SHARED ${CGI_SRC}) | ||
set_target_properties(${PROJECT_NAME}-shared PROPERTIES | ||
OUTPUT_NAME ${PROJECT_NAME} | ||
SOVERSION ${PACKAGE_MAJOR_VERSION} | ||
VERSION ${PACKAGE_VERSION} | ||
) | ||
|
||
# install binary | ||
install(TARGETS ${PROJECT_NAME}-shared | ||
EXPORT ${PROJECT_NAME}-targets | ||
LIBRARY DESTINATION "${CMAKE_INSTALL_LIBDIR}" | ||
) | ||
|
||
# install cmake targets | ||
install(EXPORT ${PROJECT_NAME}-targets | ||
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/${PROJECT_NAME}" | ||
) | ||
|
||
# install headers | ||
install(FILES | ||
cgi.h | ||
error.h | ||
session.h | ||
DESTINATION "${CMAKE_INSTALL_INCLUDEDIR}/${PROJECT_NAME}" | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
#define HAVE_MD5 0 |