summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: e646d55494c3c2d6c1c5bcbcd138a3e32d20a79e (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
################################################################################
# Cmake directives
################################################################################
cmake_minimum_required(VERSION 2.8)

################################################################################
# Project information
################################################################################
project(libuknapsack)

set(PROJECT_MAJOR_VERSION 1)
set(PROJECT_MINOR_VERSION 0)
set(PROJECT_PATCH_VERSION 0)
set(PROJECT_VERSION ${PROJECT_MAJOR_VERSION}.${PROJECT_MINOR_VERSION}.${PROJECT_PATCH_VERSION})

################################################################################
# Dependencies
################################################################################

################################################################################
# CMake
################################################################################
set(C_FLAGS_WARNING "-Wall -pedantic")
set(C_CXX_FLAGS_DEFAULT "${C_FLAGS_WARNING} -O2 -lm")

set(CMAKE_C_FLAGS "${C_CXX_FLAGS_DEFAULT} ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG   "${CMAKE_C_FLAGS} -O0 -g -DDEBUG=1")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_RELWITHDEBINFO "${CMAKE_C_FLAGS_RELEASE} -g -DDEBUG=1")

set(CMAKE_BUILD_TYPE Release CACHE STRING "default to Release")

set(CMAKE_INSTALL_PREFIX ${CMAKE_CURRENT_SOURCE_DIR}/_install)

################################################################################
# Files and install
################################################################################
set(INCLUDE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/include)
set(INCLUDE_FILES
  ${INCLUDE_DIR}/nem_ull.h
  ${INCLUDE_DIR}/dfs.h
  ${INCLUDE_DIR}/structs.h
  ${INCLUDE_DIR}/common.h
  ${INCLUDE_DIR}/random_heuristic.h
)

set(SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src)
set(SRC_FILES
  ${SRC_DIR}/nem_ull.c
  ${SRC_DIR}/dfs.c
  ${SRC_DIR}/common.c
  ${SRC_DIR}/random_heuristic.c
)

set(MAIN_SRC_DIR ${CMAKE_CURRENT_SOURCE_DIR}/src/main)

include_directories (${INCLUDE_DIR})

add_library(uknapsack STATIC ${SRC_FILES})
add_executable(uknapsack_bin ${MAIN_SRC_DIR}/uknapsack.c)
add_executable(online ${MAIN_SRC_DIR}/online.c)
add_executable(nem_ull_shuffle ${MAIN_SRC_DIR}/nem_ull_shuffle.c)

target_link_libraries(uknapsack_bin uknapsack)
target_link_libraries(online uknapsack)
target_link_libraries(nem_ull_shuffle uknapsack)

install(TARGETS uknapsack_bin DESTINATION bin)
install(TARGETS online DESTINATION bin)
install(TARGETS nem_ull_shuffle DESTINATION bin)
install(TARGETS uknapsack DESTINATION lib)
install(FILES ${INCLUDE_FILES} DESTINATION include)