| 1 | project(Thune C) |
|---|
| 2 | |
|---|
| 3 | #set(CMAKE_BUILD_TYPE Debug) |
|---|
| 4 | set(CMAKE_BUILD_TYPE Release) |
|---|
| 5 | |
|---|
| 6 | |
|---|
| 7 | # Why isn't this the default? |
|---|
| 8 | # Having to repeat the conditional expression is retarded. |
|---|
| 9 | set(CMAKE_ALLOW_LOOSE_LOOP_CONSTRUCTS true) |
|---|
| 10 | |
|---|
| 11 | set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake_modules/") |
|---|
| 12 | |
|---|
| 13 | |
|---|
| 14 | # Config defines |
|---|
| 15 | add_definitions( |
|---|
| 16 | -DLANG_THUNE |
|---|
| 17 | -DUR_CONFIG_BZIP2 |
|---|
| 18 | -DUR_CONFIG_TRIG |
|---|
| 19 | -DUR_CONFIG_MATH3D |
|---|
| 20 | -DUR_CONFIG_DATAFLOW |
|---|
| 21 | -DUR_CONFIG_FCALC |
|---|
| 22 | -DUR_CONFIG_NET |
|---|
| 23 | -DUR_CONFIG_MACROS |
|---|
| 24 | ) |
|---|
| 25 | |
|---|
| 26 | if(CMAKE_BUILD_TYPE STREQUAL "Debug") |
|---|
| 27 | add_definitions(-DDEBUG) |
|---|
| 28 | endif () |
|---|
| 29 | |
|---|
| 30 | |
|---|
| 31 | if (UNIX) |
|---|
| 32 | include_directories(. unix) |
|---|
| 33 | add_definitions(-std=c99 -pedantic -D_GNU_SOURCE) |
|---|
| 34 | set(OS_FILE unix/os.c) |
|---|
| 35 | endif () |
|---|
| 36 | |
|---|
| 37 | if (WIN32) |
|---|
| 38 | include_directories(. win32) |
|---|
| 39 | set(OS_FILE win32/os.c) |
|---|
| 40 | endif () |
|---|
| 41 | |
|---|
| 42 | |
|---|
| 43 | add_library(thune-lib SHARED |
|---|
| 44 | urlan.c |
|---|
| 45 | array.c |
|---|
| 46 | list.c |
|---|
| 47 | make.c |
|---|
| 48 | eval.c |
|---|
| 49 | thread.c |
|---|
| 50 | gc.c |
|---|
| 51 | tokenize.c |
|---|
| 52 | charset.c |
|---|
| 53 | context.c |
|---|
| 54 | print.c |
|---|
| 55 | series.c |
|---|
| 56 | parse.c |
|---|
| 57 | stdio.c |
|---|
| 58 | files.c |
|---|
| 59 | math.c |
|---|
| 60 | bignum.c |
|---|
| 61 | support/well512.c |
|---|
| 62 | ${OS_FILE} |
|---|
| 63 | ) |
|---|
| 64 | |
|---|
| 65 | set_target_properties(thune-lib PROPERTIES OUTPUT_NAME "thune") |
|---|
| 66 | |
|---|
| 67 | if (APPLE) |
|---|
| 68 | target_link_libraries(thune-lib m bz2) |
|---|
| 69 | endif () |
|---|
| 70 | if (UNIX AND NOT APPLE) |
|---|
| 71 | target_link_libraries(thune-lib m bz2 pthread) |
|---|
| 72 | endif () |
|---|
| 73 | if (WIN32) |
|---|
| 74 | target_link_libraries(thune-lib ws2_32) |
|---|
| 75 | endif () |
|---|
| 76 | |
|---|
| 77 | |
|---|
| 78 | add_executable(thune-bin console.c) |
|---|
| 79 | set_target_properties(thune-bin PROPERTIES OUTPUT_NAME "thune") |
|---|
| 80 | |
|---|
| 81 | # NOTE: This links the binary with the libraries thune-lib links against. |
|---|
| 82 | # This creates unneeded linker dependencies, but the CMake FAQ says that |
|---|
| 83 | # there is no way to change this behavior. |
|---|
| 84 | # Here is a blog entry which talks about this problem: |
|---|
| 85 | # http://blogs.sun.com/rie/entry/tt_dependencies_tt_define_what |
|---|
| 86 | |
|---|
| 87 | target_link_libraries(thune-bin thune-lib) |
|---|
| 88 | |
|---|
| 89 | |
|---|
| 90 | if (UNIX) |
|---|
| 91 | install(TARGETS thune-bin DESTINATION /usr/local/bin) |
|---|
| 92 | install(TARGETS thune-lib DESTINATION /usr/local/lib) |
|---|
| 93 | install(FILES urlan.h DESTINATION /usr/local/include) |
|---|
| 94 | endif () |
|---|
| 95 | |
|---|
| 96 | # eof |
|---|