forked from zeromq/libzmq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request zeromq#161 from mditzel/master
Issue zeromq#160: added cmake support
- Loading branch information
Showing
7 changed files
with
353 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,145 @@ | ||
################################################################# | ||
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # | ||
# Please read the README.txt file in the model directory. # | ||
################################################################# | ||
|
||
######################################################################## | ||
# Project setup | ||
######################################################################## | ||
cmake_minimum_required(VERSION 2.8) | ||
project(zyre) | ||
enable_language(C) | ||
enable_testing() | ||
|
||
set(ZYRE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set(ZYRE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
######################################################################## | ||
# determine version | ||
######################################################################## | ||
foreach(which MAJOR MINOR PATCH) | ||
file(STRINGS "${ZYRE_SOURCE_DIR}/include/zyre.h" ZYRE_VERSION_STRING REGEX "#define ZYRE_VERSION_${which}") | ||
string(REGEX MATCH "#define ZYRE_VERSION_${which} ([0-9_]+)" ZYRE_REGEX_MATCH "${ZYRE_VERSION_STRING}") | ||
if (NOT ZYRE_REGEX_MATCH) | ||
message(FATAL_ERROR "failed to parse ZYRE_VERSION_${which} from zyre.h") | ||
endif() | ||
set(ZYRE_${which}_VERSION ${CMAKE_MATCH_1}) | ||
endforeach(which) | ||
|
||
set(ZYRE_VERSION ${ZYRE_MAJOR_VERSION}.${ZYRE_MINOR_VERSION}.${ZYRE_PATCH_VERSION}) | ||
|
||
######################################################################## | ||
# platform.h | ||
######################################################################## | ||
include(CheckIncludeFile) | ||
CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H) | ||
CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_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) | ||
|
||
file(WRITE ${ZYRE_BINARY_DIR}/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(${ZYRE_BINARY_DIR}/platform.h.in ${ZYRE_BINARY_DIR}/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 ${ZYRE_SOURCE_DIR}/src/*.c) | ||
set_source_files_properties(${sources} PROPERTIES LANGUAGE CXX) | ||
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi) | ||
endif() | ||
|
||
######################################################################## | ||
# zeromq depedency | ||
######################################################################## | ||
list(APPEND CMAKE_MODULE_PATH ${ZYRE_SOURCE_DIR}) | ||
find_package(ZeroMQ REQUIRED) | ||
find_package(CZMQ REQUIRED) | ||
|
||
######################################################################## | ||
# includes | ||
######################################################################## | ||
set (zyre_headers | ||
include/zyre.h | ||
include/zyre_event.h | ||
include/zyre_log.h | ||
include/zre_log_msg.h | ||
include/zre_msg.h | ||
) | ||
source_group ("Header Files" FILES ${zyre_headers}) | ||
install(FILES ${zyre_headers} DESTINATION include) | ||
|
||
######################################################################## | ||
# library | ||
######################################################################## | ||
include_directories(${ZYRE_BINARY_DIR}) | ||
include_directories(${ZYRE_SOURCE_DIR}/include) | ||
include_directories(${CZMQ_INCLUDE_DIRS}) | ||
include_directories(${ZEROMQ_INCLUDE_DIRS}) | ||
set (zyre_sources | ||
src/zre_log_msg.c | ||
src/zre_msg.c | ||
src/zyre.c | ||
src/zyre_event.c | ||
src/zyre_group.c | ||
src/zyre_log.c | ||
src/zyre_node.c | ||
src/zyre_peer.c | ||
src/zyre_selftest.c | ||
) | ||
source_group ("Source Files" FILES ${zyre_sources}) | ||
add_library(zyre SHARED ${zyre_sources}) | ||
set_target_properties(zyre PROPERTIES DEFINE_SYMBOL "LIBZYRE_EXPORTS") | ||
target_link_libraries(zyre ${CZMQ_LIBRARIES} ${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}) | ||
|
||
install(TARGETS zyre | ||
LIBRARY DESTINATION lib${LIB_SUFFIX} # .so file | ||
ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file | ||
RUNTIME DESTINATION bin # .dll file | ||
) | ||
|
||
######################################################################## | ||
# pkgconfig | ||
######################################################################## | ||
set(VERSION "${ZYRE_VERSION}") | ||
set(prefix "${CMAKE_INSTALL_PREFIX}") | ||
set(exec_prefix "\${prefix}") | ||
set(libdir "\${prefix}/lib${LIB_SUFFIX}") | ||
set(includedir "\${prefix}/include") | ||
configure_file( | ||
${ZYRE_SOURCE_DIR}/src/libzyre.pc.in | ||
${ZYRE_BINARY_DIR}/libzyre.pc | ||
@ONLY) | ||
|
||
install( | ||
FILES ${ZYRE_BINARY_DIR}/libzyre.pc | ||
DESTINATION lib${LIB_SUFFIX}/pkgconfig | ||
) | ||
|
||
######################################################################## | ||
# tests | ||
######################################################################## | ||
add_executable(zyre_selftest ${ZYRE_SOURCE_DIR}/src/zyre_selftest.c) | ||
target_link_libraries(zyre_selftest zyre ${CZMQ_LIBRARIES} ${ZEROMQ_LIBRARIES}) | ||
add_test(zyre_selftest zyre_selftest) | ||
|
||
######################################################################## | ||
# summary | ||
######################################################################## | ||
message(STATUS "version: ${ZYRE_VERSION}") | ||
message(STATUS "install: ${CMAKE_INSTALL_PREFIX}") | ||
|
||
################################################################# | ||
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # | ||
# Please read the README.txt file in the model directory. # | ||
################################################################# |
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,18 @@ | ||
include(FindPkgConfig) | ||
PKG_CHECK_MODULES(PC_CZMQ "libczmq") | ||
|
||
find_path( | ||
CZMQ_INCLUDE_DIRS | ||
NAMES czmq.h | ||
HINTS ${PC_CZMQ_INCLUDE_DIRS} | ||
) | ||
|
||
find_library( | ||
CZMQ_LIBRARIES | ||
NAMES czmq | ||
HINTS ${PC_CZMQ_LIBRARY_DIRS} | ||
) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(CZMQ DEFAULT_MSG CZMQ_LIBRARIES CZMQ_INCLUDE_DIRS) | ||
mark_as_advanced(CZMQ_LIBRARIES CZMQ_INCLUDE_DIRS) |
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,18 @@ | ||
include(FindPkgConfig) | ||
PKG_CHECK_MODULES(PC_ZEROMQ "libzmq") | ||
|
||
find_path( | ||
ZEROMQ_INCLUDE_DIRS | ||
NAMES zmq.h | ||
HINTS ${PC_ZEROMQ_INCLUDE_DIRS} | ||
) | ||
|
||
find_library( | ||
ZEROMQ_LIBRARIES | ||
NAMES zmq | ||
HINTS ${PC_ZEROMQ_LIBRARY_DIRS} | ||
) | ||
|
||
include(FindPackageHandleStandardArgs) | ||
FIND_PACKAGE_HANDLE_STANDARD_ARGS(ZEROMQ DEFAULT_MSG ZEROMQ_LIBRARIES ZEROMQ_INCLUDE_DIRS) | ||
mark_as_advanced(ZEROMQ_LIBRARIES ZEROMQ_INCLUDE_DIRS) |
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,145 @@ | ||
.# Generate CMake project file for project | ||
.# | ||
.# This is a code generator built using the iMatix GSL code generation | ||
.# language. See https://github.com/imatix/gsl for details. This script | ||
.# is licensed under MIT/X11. | ||
.# | ||
.echo "Generating CMakeLists.txt..." | ||
.output "../CMakeLists.txt" | ||
################################################################# | ||
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # | ||
# Please read the README.txt file in the model directory. # | ||
################################################################# | ||
|
||
######################################################################## | ||
# Project setup | ||
######################################################################## | ||
cmake_minimum_required(VERSION 2.8) | ||
project($(project.name)) | ||
enable_language(C) | ||
enable_testing() | ||
|
||
set(ZYRE_SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}) | ||
set(ZYRE_BINARY_DIR ${CMAKE_CURRENT_BINARY_DIR}) | ||
|
||
######################################################################## | ||
# determine version | ||
######################################################################## | ||
foreach(which MAJOR MINOR PATCH) | ||
file(STRINGS "${ZYRE_SOURCE_DIR}/include/zyre.h" ZYRE_VERSION_STRING REGEX "#define ZYRE_VERSION_${which}") | ||
string(REGEX MATCH "#define ZYRE_VERSION_${which} ([0-9_]+)" ZYRE_REGEX_MATCH "${ZYRE_VERSION_STRING}") | ||
if (NOT ZYRE_REGEX_MATCH) | ||
message(FATAL_ERROR "failed to parse ZYRE_VERSION_${which} from zyre.h") | ||
endif() | ||
set(ZYRE_${which}_VERSION ${CMAKE_MATCH_1}) | ||
endforeach(which) | ||
|
||
set(ZYRE_VERSION ${ZYRE_MAJOR_VERSION}.${ZYRE_MINOR_VERSION}.${ZYRE_PATCH_VERSION}) | ||
|
||
######################################################################## | ||
# platform.h | ||
######################################################################## | ||
include(CheckIncludeFile) | ||
CHECK_INCLUDE_FILE("linux/wireless.h" HAVE_LINUX_WIRELESS_H) | ||
CHECK_INCLUDE_FILE("net/if.h" HAVE_NET_IF_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) | ||
|
||
file(WRITE ${ZYRE_BINARY_DIR}/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(${ZYRE_BINARY_DIR}/platform.h.in ${ZYRE_BINARY_DIR}/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 ${ZYRE_SOURCE_DIR}/src/*.c) | ||
set_source_files_properties(${sources} PROPERTIES LANGUAGE CXX) | ||
set(MORE_LIBRARIES ws2_32 Rpcrt4 Iphlpapi) | ||
endif() | ||
|
||
######################################################################## | ||
# zeromq depedency | ||
######################################################################## | ||
list(APPEND CMAKE_MODULE_PATH ${ZYRE_SOURCE_DIR}) | ||
find_package(ZeroMQ REQUIRED) | ||
find_package(CZMQ REQUIRED) | ||
|
||
######################################################################## | ||
# includes | ||
######################################################################## | ||
set (zyre_headers | ||
.for header | ||
include/$(name).h | ||
.endfor | ||
) | ||
source_group ("Header Files" FILES ${zyre_headers}) | ||
install(FILES ${zyre_headers} DESTINATION include) | ||
|
||
######################################################################## | ||
# library | ||
######################################################################## | ||
include_directories(${ZYRE_BINARY_DIR}) | ||
include_directories(${ZYRE_SOURCE_DIR}/include) | ||
include_directories(${CZMQ_INCLUDE_DIRS}) | ||
include_directories(${ZEROMQ_INCLUDE_DIRS}) | ||
set (zyre_sources | ||
.for class | ||
src/$(name).c | ||
.endfor | ||
) | ||
source_group ("Source Files" FILES ${zyre_sources}) | ||
add_library($(project.name) SHARED ${zyre_sources}) | ||
set_target_properties($(project.name) PROPERTIES DEFINE_SYMBOL "LIBZYRE_EXPORTS") | ||
target_link_libraries($(project.name) ${CZMQ_LIBRARIES} ${ZEROMQ_LIBRARIES} ${MORE_LIBRARIES}) | ||
|
||
install(TARGETS $(project.name) | ||
LIBRARY DESTINATION lib${LIB_SUFFIX} # .so file | ||
ARCHIVE DESTINATION lib${LIB_SUFFIX} # .lib file | ||
RUNTIME DESTINATION bin # .dll file | ||
) | ||
|
||
######################################################################## | ||
# pkgconfig | ||
######################################################################## | ||
set(VERSION "${ZYRE_VERSION}") | ||
set(prefix "${CMAKE_INSTALL_PREFIX}") | ||
set(exec_prefix "\\${prefix}") | ||
set(libdir "\\${prefix}/lib${LIB_SUFFIX}") | ||
set(includedir "\\${prefix}/include") | ||
configure_file( | ||
${ZYRE_SOURCE_DIR}/src/libzyre.pc.in | ||
${ZYRE_BINARY_DIR}/libzyre.pc | ||
@ONLY) | ||
|
||
install( | ||
FILES ${ZYRE_BINARY_DIR}/libzyre.pc | ||
DESTINATION lib${LIB_SUFFIX}/pkgconfig | ||
) | ||
|
||
######################################################################## | ||
# tests | ||
######################################################################## | ||
add_executable(zyre_selftest ${ZYRE_SOURCE_DIR}/src/zyre_selftest.c) | ||
target_link_libraries(zyre_selftest zyre ${CZMQ_LIBRARIES} ${ZEROMQ_LIBRARIES}) | ||
add_test(zyre_selftest zyre_selftest) | ||
|
||
######################################################################## | ||
# summary | ||
######################################################################## | ||
message(STATUS "version: ${ZYRE_VERSION}") | ||
message(STATUS "install: ${CMAKE_INSTALL_PREFIX}") | ||
|
||
################################################################# | ||
# GENERATED SOURCE CODE, DO NOT EDIT EXCEPT EXPERIMENTALLY # | ||
# Please read the README.txt file in the model directory. # | ||
################################################################# |
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,6 @@ | ||
# Run all code generation scripts | ||
# Requires iMatix GSL4, from http://github.com/imatix/gsl | ||
# Use this when: | ||
# - add a new project class (project.xml) | ||
|
||
gsl -q -script:project.gsl project.xml |
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,5 @@ | ||
.# This is a code generator built using the iMatix GSL code generation | ||
.# language. See https://github.com/imatix/gsl for details. This script | ||
.# is licensed under MIT/X11. | ||
.# | ||
.include "build-cmake.gsl" |
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,16 @@ | ||
<project name = "zyre"> | ||
<header name = "zyre" /> | ||
<header name = "zyre_event" /> | ||
<header name = "zyre_log" /> | ||
<header name = "zre_log_msg" /> | ||
<header name = "zre_msg" /> | ||
<class name = "zre_log_msg" /> | ||
<class name = "zre_msg" /> | ||
<class name = "zyre" /> | ||
<class name = "zyre_event" /> | ||
<class name = "zyre_group" /> | ||
<class name = "zyre_log" /> | ||
<class name = "zyre_node" /> | ||
<class name = "zyre_peer" /> | ||
<class name = "zyre_selftest" /> | ||
</project> |