2017-02-19 19:48:01 +00:00
|
|
|
#cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
|
|
|
|
#project(clsocket)
|
2017-02-19 18:25:55 +00:00
|
|
|
|
|
|
|
# set up versioning.
|
2017-02-19 19:48:01 +00:00
|
|
|
#set(BUILD_MAJOR "1")
|
|
|
|
#set(BUILD_MINOR "4")
|
|
|
|
#set(BUILD_VERSION "3")
|
2017-02-19 18:25:55 +00:00
|
|
|
|
2017-09-11 04:20:54 +00:00
|
|
|
include_directories(src)
|
|
|
|
|
2017-02-19 18:25:55 +00:00
|
|
|
SET(CLSOCKET_HEADERS
|
|
|
|
src/ActiveSocket.h
|
|
|
|
src/Host.h
|
|
|
|
src/PassiveSocket.h
|
|
|
|
src/SimpleSocket.h
|
|
|
|
src/StatTimer.h
|
|
|
|
)
|
|
|
|
|
|
|
|
SET(CLSOCKET_SOURCES
|
|
|
|
src/SimpleSocket.cpp
|
|
|
|
src/ActiveSocket.cpp
|
|
|
|
src/PassiveSocket.cpp
|
|
|
|
)
|
|
|
|
|
|
|
|
# mark headers as headers...
|
|
|
|
SET_SOURCE_FILES_PROPERTIES( ${CLSOCKET_HEADERS} PROPERTIES HEADER_FILE_ONLY TRUE )
|
|
|
|
# append to sources so that dependency checks work on headers
|
|
|
|
LIST(APPEND CLSOCKET_SOURCES ${CLSOCKET_HEADERS})
|
|
|
|
|
|
|
|
# OS and compiler checks.
|
|
|
|
if(UNIX)
|
|
|
|
# linux / normal unix
|
2017-04-14 19:43:45 +00:00
|
|
|
add_definitions(${OSDEF})
|
2017-02-19 18:25:55 +00:00
|
|
|
elseif(WIN32)
|
|
|
|
add_definitions(-DWIN32)
|
|
|
|
SET(PROJECT_LIBS Ws2_32.lib)
|
|
|
|
if(MINGW)
|
|
|
|
# Special MINGW stuff here
|
|
|
|
elseif(MSVC)
|
|
|
|
# Special MSVC stuff here
|
2017-02-19 19:48:01 +00:00
|
|
|
add_definitions(-D_WINSOCK_DEPRECATED_NO_WARNINGS)
|
2017-02-19 18:25:55 +00:00
|
|
|
else()
|
|
|
|
# No idea what it is, but there's a good chance it's too weird.
|
|
|
|
MESSAGE( FATAL_ERROR "Using unknown WIN32 compiler... NOT. Please add to build system." )
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
|
2017-02-19 19:48:01 +00:00
|
|
|
OPTION(CLSOCKET_SHARED "Build clsocket lib as shared." OFF)
|
2017-02-19 18:25:55 +00:00
|
|
|
OPTION(CLSOCKET_DEP_ONLY "Build for use inside other CMake projects as dependency." OFF)
|
|
|
|
|
|
|
|
# make the lib
|
|
|
|
if(CLSOCKET_SHARED)
|
|
|
|
if(CLSOCKET_DEP_ONLY)
|
|
|
|
ADD_LIBRARY(clsocket SHARED EXCLUDE_FROM_ALL ${CLSOCKET_SOURCES})
|
|
|
|
else()
|
|
|
|
ADD_LIBRARY(clsocket SHARED ${CLSOCKET_SOURCES})
|
|
|
|
endif()
|
|
|
|
else()
|
|
|
|
if(CLSOCKET_DEP_ONLY)
|
|
|
|
ADD_LIBRARY(clsocket STATIC EXCLUDE_FROM_ALL ${CLSOCKET_SOURCES})
|
|
|
|
else()
|
|
|
|
ADD_LIBRARY(clsocket STATIC ${CLSOCKET_SOURCES})
|
|
|
|
endif()
|
|
|
|
endif()
|
|
|
|
TARGET_LINK_LIBRARIES(clsocket ${PROJECT_LIBS})
|
|
|
|
|
|
|
|
# install into configured prefix
|
|
|
|
if(NOT CLSOCKET_DEP_ONLY)
|
2017-09-11 04:20:54 +00:00
|
|
|
install(TARGETS clsocket ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
|
2017-02-19 18:25:55 +00:00
|
|
|
install(FILES ${CLSOCKET_HEADERS} DESTINATION include)
|
|
|
|
else()
|
|
|
|
|
|
|
|
endif()
|
|
|
|
|