################################################################################ # 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) target_link_libraries(uknapsack_bin uknapsack) target_link_libraries(online uknapsack) install(TARGETS uknapsack_bin DESTINATION bin) install(TARGETS online DESTINATION bin) install(TARGETS uknapsack DESTINATION lib) install(FILES ${INCLUDE_FILES} DESTINATION include)