~
[scx.git] / CMakeLists.txt
blobaa26dc996b848e1ab137c14fed26b6859dea771c
1 project(SCX)
2 cmake_minimum_required(VERSION 2.8)
4 set(IS_FREEBSD "${CMAKE_SYSTEM}" MATCHES "FreeBSD")
5 set(IS_LINUX "${CMAKE_SYSTEM}" MATCHES "Linux")
7 set(CMAKE_CXX_FLAGS_RELEASE "$ENV{CXXFLAGS} -O2 -pipe -Wall")
8 set(CMAKE_CXX_FLAGS_DEBUG "$ENV{CXXFLAGS} -g -pipe -Wall")
10 set(OUTPUT_DIR ${FOO_SOURCE_DIR}/build/${CMAKE_BUILD_TYPE})
11 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${OUTPUT_DIR})
12 set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${OUTPUT_DIR})
14 include_directories(SYSTEM /usr/local/include)
15 link_directories(/usr/local/lib)
17 option(EnableLog "Verbose output" off)
18 if (EnableLog)
19     add_definitions(-DSCX_LOG)
20 endif()
22 option(EnableClang "Use Clang C compiler" off)
23 if (EnableClang)
24     set(CMAKE_C_COMPILER "clang")
25     set(CMAKE_CXX_COMPILER "clang++")
26 endif()
28 option(EnableGCC46 "Use GCC46 compiler" off)
29 if (EnableGCC46)
30     set(CMAKE_C_COMPILER "gcc46")
31     set(CMAKE_CXX_COMPILER "g++46")
32 endif()
34 option(EnableTR1 "Compare with GCC TR1" on)
35 if (EnableTR1)
36     add_definitions(-DTR1)
37 endif()
39 option(EnableBoost "Compare with Boost" off)
40 if (EnableBoost)
41     add_definitions(-DBOOST)
42 endif()
44 message("CMake:         " ${CMAKE_VERSION})
45 message("OS Name:       " ${CMAKE_SYSTEM_NAME})
46 message("OS Version:    " ${CMAKE_SYSTEM_VERSION})
47 message("C Compiler:    " ${CMAKE_C_COMPILER})
48 message("C++ Compiler:  " ${CMAKE_CXX_COMPILER})
49 message("Precessor:     " ${CMAKE_SYSTEM_PROCESSOR})
50 message("Build type:    " ${CMAKE_BUILD_TYPE})
51 message("Project root:  " ${FOO_SOURCE_DIR})
52 message("Ouput root:    " ${OUTPUT_DIR})
54 add_executable(alias tests/alias.cpp)
56 add_executable(colstr tests/colstr.cpp)
58 add_executable(conv tests/conv.cpp)
60 add_executable(function tests/function.cpp)
62 add_executable(signal tests/signal.cpp)
63 if(IS_LINUX)
64     target_link_libraries(signal -lrt)
65 endif()
67 add_executable(runtimer tests/runtimer.cpp)
68 if(IS_LINUX)
69     target_link_libraries(runtimer -lrt)
70 endif()
72 add_executable(thread tests/thread.cpp)
73 target_link_libraries(thread -pthread)
75 add_executable(html tests/html.cpp)
77 add_executable(math tests/math.cpp)
79 #add_executable(log tests/log.cpp)
80 #target_link_libraries(thread pthread)
82 add_executable(kv tests/kv.cpp)
83 if(IS_LINUX)
84     target_link_libraries(kv -lsqlite3 -lrt)
85 else()
86     target_link_libraries(kv -lsqlite3)
87 endif()
89 add_executable(hash tests/hash.cpp)
91 add_executable(condvar tests/condvar.cpp)
92 target_link_libraries(condvar -pthread)
94 add_executable(pvbuffer tests/pvbuffer.cpp)
95 target_link_libraries(pvbuffer -pthread)
97 add_executable(socket tests/socket.cpp)
98 target_link_libraries(socket -pthread)
100 add_executable(singleton tests/singleton.cpp)
101 target_link_libraries(singleton -pthread)
103 add_executable(queue tests/queue.cpp)
105 add_executable(stack tests/stack.cpp)
107 add_executable(stlutils tests/stlutils.cpp)
109 add_executable(mempool tests/mempool.cpp)
111 add_executable(filehelp tests/filehelp.cpp)