summaryrefslogtreecommitdiffstats
path: root/CMakeLists.txt
blob: da3c722094db9ae278bdf2775ffb20bb9cf2d1c5 (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
################################################################################
# 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
)

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

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

include_directories (${INCLUDE_DIR})

add_library(uknapsack STATIC ${SRC_FILES})

add_executable(nem_ull ${MAIN_SRC_DIR}/nem_ull.c)
add_executable(dfs ${MAIN_SRC_DIR}/dfs.c)

target_link_libraries(nem_ull uknapsack)
target_link_libraries(dfs uknapsack)

install(TARGETS nem_ull DESTINATION bin)
install(TARGETS dfs DESTINATION bin)
install(TARGETS uknapsack DESTINATION lib)
install(FILES ${INCLUDE_FILES} DESTINATION include)