-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Problem: need to move to serious project
Solution: bootstrap new zproject project
- Loading branch information
Michal Vyskocil
committed
Feb 3, 2017
1 parent
b205f7d
commit c2e6009
Showing
30 changed files
with
2,911 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 |
---|---|---|
@@ -0,0 +1,4 @@ | ||
# This is a skeleton created by zproject. | ||
# You can add hand-written code here. | ||
# disables auto CRLF conversion for all files; create the file correctly and it will be allright | ||
* -text |
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,346 @@ | ||
################################################################################ | ||
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # | ||
# Read the zproject/README.md for information about making permanent changes. # | ||
################################################################################ | ||
|
||
######################################################################## | ||
# Project setup | ||
######################################################################## | ||
cmake_minimum_required(VERSION 2.8) | ||
project(zmosq) | ||
enable_language(C) | ||
enable_testing() | ||
|
||
set(SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}") | ||
set(CMAKE_EXPORT_COMPILE_COMMANDS 1) | ||
# Select flags | ||
SET(CMAKE_C_FLAGS_RELEASE "-O3") | ||
|
||
# Will be used to add flags to pkg-config useful when apps want to statically link | ||
set(pkg_config_libs_private "") | ||
|
||
######################################################################## | ||
# options | ||
######################################################################## | ||
OPTION (ENABLE_DRAFTS "Build and install draft classes and methods" ON) | ||
IF (ENABLE_DRAFTS) | ||
ADD_DEFINITIONS (-DZMSQ_BUILD_DRAFT_API) | ||
ENDIF (ENABLE_DRAFTS) | ||
|
||
######################################################################## | ||
# platform.h | ||
######################################################################## | ||
include(CheckIncludeFile) | ||
CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H) | ||
CHECK_INCLUDE_FILE("net/if_media.h" HAVE_NET_IF_MEDIA_H) | ||
|
||
include(CheckFunctionExists) | ||
CHECK_FUNCTION_EXISTS("getifaddrs" HAVE_GETIFADDRS) | ||
CHECK_FUNCTION_EXISTS("freeifaddrs" HAVE_FREEIFADDRS) | ||
|
||
include(CheckIncludeFiles) | ||
check_include_files("sys/socket.h;net/if.h" HAVE_NET_IF_H) | ||
if (NOT HAVE_NET_IF_H) | ||
CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_H) | ||
endif() | ||
|
||
file(WRITE "${SOURCE_DIR}/src/platform.h.in" " | ||
#cmakedefine HAVE_LINUX_WIRELESS_H | ||
#cmakedefine HAVE_NET_IF_H | ||
#cmakedefine HAVE_NET_IF_MEDIA_H | ||
#cmakedefine HAVE_GETIFADDRS | ||
#cmakedefine HAVE_FREEIFADDRS | ||
") | ||
|
||
configure_file("${SOURCE_DIR}/src/platform.h.in" "${SOURCE_DIR}/src/platform.h") | ||
|
||
#The MSVC C compiler is too out of date, | ||
#so the sources have to be compiled as c++ | ||
if (MSVC) | ||
enable_language(CXX) | ||
file(GLOB sources "${SOURCE_DIR}/src/*.c") | ||
set_source_files_properties( | ||
${sources} | ||
PROPERTIES LANGUAGE CXX | ||
) | ||
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi) | ||
endif() | ||
|
||
# required libraries for mingw | ||
if (MINGW) | ||
set(MORE_LIBRARIES -lws2_32 -lrpcrt4 -liphlpapi) | ||
endif() | ||
|
||
# required libraries for cygwin | ||
if (CYGWIN) | ||
set(MORE_LIBRARIES) | ||
endif() | ||
|
||
list(APPEND CMAKE_MODULE_PATH "${SOURCE_DIR}") | ||
set(OPTIONAL_LIBRARIES) | ||
|
||
######################################################################## | ||
# LIBZMQ dependency | ||
######################################################################## | ||
find_package(libzmq REQUIRED) | ||
IF (LIBZMQ_FOUND) | ||
include_directories(${LIBZMQ_INCLUDE_DIRS}) | ||
list(APPEND MORE_LIBRARIES ${LIBZMQ_LIBRARIES}) | ||
set(pkg_config_libs_private "${pkg_config_libs_private} -lzmq") | ||
ELSE (LIBZMQ_FOUND) | ||
message( FATAL_ERROR "libzmq not found." ) | ||
ENDIF (LIBZMQ_FOUND) | ||
|
||
######################################################################## | ||
# CZMQ dependency | ||
######################################################################## | ||
find_package(czmq REQUIRED) | ||
IF (CZMQ_FOUND) | ||
include_directories(${CZMQ_INCLUDE_DIRS}) | ||
list(APPEND MORE_LIBRARIES ${CZMQ_LIBRARIES}) | ||
set(pkg_config_libs_private "${pkg_config_libs_private} -lczmq") | ||
ELSE (CZMQ_FOUND) | ||
message( FATAL_ERROR "czmq not found." ) | ||
ENDIF (CZMQ_FOUND) | ||
|
||
######################################################################## | ||
# MALAMUTE dependency | ||
######################################################################## | ||
find_package(malamute REQUIRED) | ||
IF (MALAMUTE_FOUND) | ||
include_directories(${MALAMUTE_INCLUDE_DIRS}) | ||
list(APPEND MORE_LIBRARIES ${MALAMUTE_LIBRARIES}) | ||
set(pkg_config_libs_private "${pkg_config_libs_private} -lmlm") | ||
ELSE (MALAMUTE_FOUND) | ||
message( FATAL_ERROR "malamute not found." ) | ||
ENDIF (MALAMUTE_FOUND) | ||
|
||
######################################################################## | ||
# MOSQUITTO dependency | ||
######################################################################## | ||
find_package(mosquitto REQUIRED) | ||
IF (MOSQUITTO_FOUND) | ||
include_directories(${MOSQUITTO_INCLUDE_DIRS}) | ||
list(APPEND MORE_LIBRARIES ${MOSQUITTO_LIBRARIES}) | ||
set(pkg_config_libs_private "${pkg_config_libs_private} -lmosquitto") | ||
ELSE (MOSQUITTO_FOUND) | ||
message( FATAL_ERROR "mosquitto not found." ) | ||
ENDIF (MOSQUITTO_FOUND) | ||
|
||
######################################################################## | ||
# includes | ||
######################################################################## | ||
set (zmsq_headers | ||
include/zmsq_library.h | ||
include/zmosq.h | ||
) | ||
|
||
IF (ENABLE_DRAFTS) | ||
list(APPEND zmsq_headers | ||
include/zmosq_server.h | ||
include/zmosq_client.h | ||
include/zmosq_server.h | ||
) | ||
ENDIF (ENABLE_DRAFTS) | ||
|
||
source_group ("Header Files" FILES ${zmsq_headers}) | ||
install(FILES ${zmsq_headers} DESTINATION include) | ||
|
||
######################################################################## | ||
# library | ||
######################################################################## | ||
include_directories("${SOURCE_DIR}/src" "${SOURCE_DIR}/include") | ||
set (zmsq_sources | ||
) | ||
|
||
IF (ENABLE_DRAFTS) | ||
list (APPEND zmsq_sources | ||
src/zmosq_server.c | ||
src/zmosq_client.c | ||
src/zmosq_server.c | ||
) | ||
ENDIF (ENABLE_DRAFTS) | ||
|
||
IF (ENABLE_DRAFTS) | ||
list (APPEND zmsq_sources | ||
src/zmsq_private_selftest.c | ||
) | ||
ENDIF (ENABLE_DRAFTS) | ||
|
||
source_group("Source Files" FILES ${zmsq_sources}) | ||
if (NOT DEFINED BUILD_SHARED_LIBS) | ||
SET(BUILD_SHARED_LIBS ON) | ||
endif() | ||
add_library(zmsq ${zmsq_sources}) | ||
set_target_properties(zmsq | ||
PROPERTIES DEFINE_SYMBOL "ZMSQ_EXPORTS" | ||
) | ||
set_target_properties (zmsq | ||
PROPERTIES SOVERSION "0.0.0" | ||
) | ||
target_link_libraries(zmsq | ||
${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES} | ||
) | ||
|
||
install(TARGETS zmsq | ||
LIBRARY DESTINATION "lib${LIB_SUFFIX}" # .so file | ||
ARCHIVE DESTINATION "lib${LIB_SUFFIX}" # .lib file | ||
RUNTIME DESTINATION bin # .dll file | ||
) | ||
|
||
######################################################################## | ||
# pkgconfig | ||
######################################################################## | ||
set (VERSION "0.1.0") | ||
set (prefix "${CMAKE_INSTALL_PREFIX}") | ||
set (exec_prefix "\${prefix}") | ||
set (libdir "\${prefix}/lib${LIB_SUFFIX}") | ||
set (includedir "\${prefix}/include") | ||
IF (ENABLE_DRAFTS) | ||
set (pkg_config_defines "-DZMSQ_BUILD_DRAFT_API=1") | ||
ELSE (ENABLE_DRAFTS) | ||
set (pkg_config_defines "") | ||
ENDIF (ENABLE_DRAFTS) | ||
configure_file( | ||
"${SOURCE_DIR}/src/libzmsq.pc.in" | ||
"${SOURCE_DIR}/src/libzmsq.pc" | ||
@ONLY) | ||
|
||
install( | ||
FILES "${SOURCE_DIR}/src/libzmsq.pc" | ||
DESTINATION "lib${LIB_SUFFIX}/pkgconfig" | ||
) | ||
|
||
######################################################################## | ||
# executables | ||
######################################################################## | ||
add_executable( | ||
zmsq_selftest | ||
"${SOURCE_DIR}/src/zmsq_selftest.c" | ||
) | ||
target_link_libraries( | ||
zmsq_selftest | ||
zmsq | ||
${LIBZMQ_LIBRARIES} | ||
${CZMQ_LIBRARIES} | ||
${MALAMUTE_LIBRARIES} | ||
${MOSQUITTO_LIBRARIES} | ||
${OPTIONAL_LIBRARIES} | ||
) | ||
|
||
######################################################################## | ||
# tests | ||
######################################################################## | ||
set(CLASSTEST_TIMEOUT 60 CACHE STRING "Timeout of the selftest of a class") | ||
set(TOTAL_TIMEOUT 600 CACHE STRING "Timout of the total testsuite") | ||
|
||
if(UNIX) | ||
find_program(MEMORYCHECK_COMMAND valgrind) | ||
set(MEMORYCHECK_COMMAND_OPTIONS "--leak-check=full --show-reachable=yes | ||
--error-exitcode=1 | ||
--suppressions=src/.valgrind.supp") | ||
endif() | ||
|
||
set(TEST_CLASSES | ||
) | ||
|
||
IF (ENABLE_DRAFTS) | ||
list (APPEND TEST_CLASSES | ||
zmosq_server | ||
zmosq_client | ||
zmosq_server | ||
) | ||
ENDIF (ENABLE_DRAFTS) | ||
|
||
IF (ENABLE_DRAFTS) | ||
list (APPEND TEST_CLASSES | ||
private_classes | ||
) | ||
ENDIF (ENABLE_DRAFTS) | ||
|
||
foreach(TEST_CLASS ${TEST_CLASSES}) | ||
add_test( | ||
NAME ${TEST_CLASS} | ||
COMMAND zmsq_selftest --continue --verbose --test ${TEST_CLASS} | ||
) | ||
set_tests_properties( | ||
${TEST_CLASS} | ||
PROPERTIES TIMEOUT ${CLASSTEST_TIMEOUT} | ||
) | ||
endforeach(TEST_CLASS) | ||
|
||
include(CTest) | ||
|
||
######################################################################## | ||
# cleanup | ||
######################################################################## | ||
add_custom_target (distclean @echo Cleaning for source distribution) | ||
|
||
set(cmake_generated ${CMAKE_BINARY_DIR}/CMakeCache.txt | ||
${CMAKE_BINARY_DIR}/cmake_install.cmake | ||
${CMAKE_BINARY_DIR}/Makefile | ||
${CMAKE_BINARY_DIR}/CMakeFiles | ||
${CMAKE_BINARY_DIR}/CTestTestfile.cmake | ||
${CMAKE_BINARY_DIR}/DartConfiguration.tcl | ||
${CMAKE_BINARY_DIR}/Testing | ||
${CMAKE_BINARY_DIR}/compile_commands.json | ||
${CMAKE_BINARY_DIR}/src/platform.h | ||
${CMAKE_BINARY_DIR}/src/libzmsq.pc | ||
${CMAKE_BINARY_DIR}/src/libzmsq.so | ||
${CMAKE_BINARY_DIR}/src/zmosq_selftest | ||
${CMAKE_BINARY_DIR}/src/zmsq_selftest | ||
) | ||
|
||
add_custom_command( | ||
DEPENDS clean | ||
COMMENT "distribution clean" | ||
COMMAND rm | ||
ARGS -rf CMakeTmp ${cmake_generated} | ||
TARGET distclean | ||
) | ||
|
||
######################################################################## | ||
# summary | ||
######################################################################## | ||
message ("") | ||
message (STATUS "******************* Configuration Summary *******************") | ||
message (STATUS "General:") | ||
message (STATUS " Version : ${VERSION}") | ||
message (STATUS " System : ${CMAKE_SYSTEM_NAME}") | ||
message (STATUS " C compiler : ${CMAKE_C_COMPILER}") | ||
message (STATUS " Debug C flags : ${CMAKE_C_FLAGS_DEBUG} ${CMAKE_C_FLAGS}") | ||
message (STATUS " Release C flags : ${CMAKE_C_FLAGS_RELEASE} ${CMAKE_C_FLAGS}") | ||
message (STATUS " Build type : ${CMAKE_BUILD_TYPE}") | ||
IF (ENABLE_DRAFTS) | ||
message (STATUS " Draft API : Yes") | ||
ELSE (ENABLE_DRAFTS) | ||
message (STATUS " Draft API : No") | ||
ENDIF (ENABLE_DRAFTS) | ||
message (STATUS "") | ||
message (STATUS "Dependencies:") | ||
include(FeatureSummary) | ||
feature_summary (WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) | ||
message (STATUS "") | ||
message (STATUS "Install:") | ||
message (STATUS " Install prefix :" "${CMAKE_INSTALL_PREFIX}") | ||
message (STATUS "") | ||
message (STATUS "************************* Options ***************************") | ||
message (STATUS "Options:") | ||
message (STATUS " Use the Draft API (default = yes):") | ||
message (STATUS " -DENABLE-DRAFTS=[yes|no]") | ||
message (STATUS "") | ||
message (STATUS "*************************************************************") | ||
message (STATUS "Configuration complete! Now procced with:") | ||
message (STATUS " 'make' compile the project") | ||
message (STATUS " 'make test' run the project's selftest") | ||
message (STATUS " 'make install' install the project to ${CMAKE_INSTALL_PREFIX}") | ||
message (STATUS "") | ||
message (STATUS "Further options are:") | ||
message (STATUS " 'ctest -T memcheck' run the project's selftest with") | ||
message (STATUS " valgrind to check for memory leaks") | ||
message (STATUS "") | ||
|
||
################################################################################ | ||
# THIS FILE IS 100% GENERATED BY ZPROJECT; DO NOT EDIT EXCEPT EXPERIMENTALLY # | ||
# Read the zproject/README.md for information about making permanent changes. # | ||
################################################################################ |
Oops, something went wrong.