summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPetr Mrázek2012-03-11 15:50:03 +0100
committerPetr Mrázek2012-03-11 15:50:03 +0100
commitf8a2b0977253079b66d4ec14d5fceaa8458d11d6 (patch)
tree6d55342a6aca04935311af095654255baa066252
parent7ef04f1dfc0e66621dafd52201b48ab77cfff770 (diff)
downloadclsocket-f8a2b0977253079b66d4ec14d5fceaa8458d11d6.tar.gz
clsocket-f8a2b0977253079b66d4ec14d5fceaa8458d11d6.tar.bz2
clsocket-f8a2b0977253079b66d4ec14d5fceaa8458d11d6.tar.xz
Add CMake build system.
-rw-r--r--CMakeLists.txt76
1 files changed, 76 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt
new file mode 100644
index 0000000..a737ba0
--- /dev/null
+++ b/CMakeLists.txt
@@ -0,0 +1,76 @@
+cmake_minimum_required(VERSION 2.8 FATAL_ERROR)
+project(clsocket)
+
+# set up versioning.
+set(BUILD_MAJOR "1")
+set(BUILD_MINOR "4")
+set(BUILD_VERSION "3")
+
+include_directories(src)
+
+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)
+ if(CYGWIN)
+ # Special Cygwin stuff here
+ elseif(APPLE)
+ # Special Apple stuff here
+ endif()
+ # linux / normal unix
+ add_definitions(-D_LINUX)
+elseif(WIN32)
+ add_definitions(-DWIN32)
+ SET(PROJECT_LIBS Ws2_32.lib)
+ if(MINGW)
+ # Special MINGW stuff here
+ elseif(MSVC)
+ # Special MSVC stuff here
+ 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()
+
+OPTION(CLSOCKET_SHARED "Build clsocket lib as shared." ON)
+
+# make the lib
+if(CLSOCKET_SHARED)
+ ADD_LIBRARY(clsocket SHARED ${CLSOCKET_SOURCES})
+else()
+ ADD_LIBRARY(clsocket STATIC ${CLSOCKET_SOURCES})
+endif()
+
+TARGET_LINK_LIBRARIES(clsocket ${PROJECT_LIBS})
+
+# install into configured prefix
+install(TARGETS clsocket ARCHIVE DESTINATION lib LIBRARY DESTINATION lib)
+install(FILES ${CLSOCKET_HEADERS} DESTINATION include)
+
+if(UNIX)
+ OPTION(CLSOCKET_EXAMPLES "Build the examples" OFF)
+
+ if(CLSOCKET_EXAMPLES)
+ ADD_EXECUTABLE(clsocket-example examples/RecvAsync.cpp)
+ TARGET_LINK_LIBRARIES(clsocket-example clsocket pthread)
+ install(TARGETS clsocket-example DESTINATION bin)
+ endif()
+endif()
+