2017-03-23 01:03:33 -07:00
|
|
|
cmake_minimum_required(VERSION 3.7.2)
|
2017-03-23 01:03:56 -07:00
|
|
|
project(cellar CXX)
|
|
|
|
set(CMAKE_CXX_STANDARD 11)
|
|
|
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
2017-03-23 01:03:33 -07:00
|
|
|
|
2017-03-28 12:41:25 -07:00
|
|
|
set(CMAKE_CXX_FLAGS "-pipe")
|
|
|
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
|
|
|
set(CMAKE_CXX_FLAGS_RELWITHDBGINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
|
2017-03-27 21:03:35 -07:00
|
|
|
|
|
|
|
if(NOT CMAKE_BUILD_TYPE)
|
|
|
|
message(STATUS "Assuming this is a release build. -DCMAKE_BUILD_TYPE=Debug otherwise.")
|
|
|
|
set(CMAKE_BUILD_TYPE Release FORCE)
|
|
|
|
endif(NOT CMAKE_BUILD_TYPE)
|
|
|
|
|
2017-03-23 14:23:22 -07:00
|
|
|
# local cmake modules
|
|
|
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
|
|
|
|
2017-03-23 13:36:38 -07:00
|
|
|
# for installation rules, from CMake wiki
|
|
|
|
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/cellar")
|
|
|
|
|
|
|
|
# add the automatically determined parts of the RPATH
|
|
|
|
# which point to directories outside the build tree to the install RPATH
|
|
|
|
SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|
|
|
|
2017-07-05 13:13:04 -07:00
|
|
|
include(Git)
|
|
|
|
git_init()
|
|
|
|
|
2017-06-28 19:22:34 -07:00
|
|
|
include(Ronn)
|
|
|
|
|
2017-03-23 01:03:33 -07:00
|
|
|
find_package(PythonInterp)
|
2017-03-23 14:23:22 -07:00
|
|
|
find_package(PythonModule)
|
|
|
|
find_python_module(cogapp REQUIRED)
|
|
|
|
|
2017-03-23 01:03:56 -07:00
|
|
|
find_package(Boost 1.63 REQUIRED COMPONENTS filesystem)
|
2017-03-23 01:03:33 -07:00
|
|
|
|
2017-03-23 11:13:00 -07:00
|
|
|
find_package(PkgConfig)
|
|
|
|
pkg_check_modules(TCLAP "tclap >= 1.2.1")
|
|
|
|
if(NOT TCLAP_FOUND)
|
|
|
|
MESSAGE(WARNING "TCLAP is required by this project, but was not found by CMake.
|
|
|
|
Continuing on the assumption that you've downloaded it from
|
|
|
|
http://tclap.sourceforge.net and put the headers in ./include
|
|
|
|
(wink, nudge)")
|
|
|
|
endif(NOT TCLAP_FOUND)
|
|
|
|
|
2017-07-05 13:13:04 -07:00
|
|
|
include_directories("${CMAKE_SOURCE_DIR}/include")
|
|
|
|
configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in"
|
|
|
|
"${CMAKE_CURRENT_BINARY_DIR}/include/cmake.hpp")
|
|
|
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
|
2017-03-23 18:22:09 -07:00
|
|
|
set(src "${CMAKE_SOURCE_DIR}/src")
|
2017-03-23 01:03:33 -07:00
|
|
|
|
|
|
|
set(coggedfiles)
|
|
|
|
|
2017-03-23 18:22:09 -07:00
|
|
|
file(GLOB_RECURSE cogfiles RELATIVE "${CMAKE_SOURCE_DIR}"
|
|
|
|
"${CMAKE_SOURCE_DIR}/*.cog")
|
2017-03-23 01:03:33 -07:00
|
|
|
|
|
|
|
foreach(cogfile ${cogfiles})
|
2017-07-05 13:24:28 -07:00
|
|
|
# thisfile = absolute path to output file
|
|
|
|
# outfile = relative path
|
|
|
|
# TODO: fix that
|
2017-03-23 01:03:56 -07:00
|
|
|
string(REGEX REPLACE ".cog\$" "" outfile "${cogfile}")
|
2017-07-05 13:24:28 -07:00
|
|
|
set(thisfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
|
2017-03-23 01:03:33 -07:00
|
|
|
|
2017-03-23 14:43:48 -07:00
|
|
|
add_custom_command(OUTPUT "${thisfile}" PRE_BUILD
|
2017-07-05 13:24:28 -07:00
|
|
|
COMMAND ${PYTHON_EXECUTABLE} -m cogapp -d -o "${thisfile}" "${cogfile}"
|
2017-03-23 01:03:33 -07:00
|
|
|
DEPENDS ${cogfile}
|
2017-03-23 18:22:09 -07:00
|
|
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
2017-03-24 15:57:49 -07:00
|
|
|
COMMENT "Greasing the cog for ${outfile}")
|
2017-03-23 01:03:33 -07:00
|
|
|
|
2017-03-23 01:03:56 -07:00
|
|
|
set(coggedfiles ${coggedfiles} "${thisfile}")
|
2017-03-23 01:03:33 -07:00
|
|
|
endforeach(cogfile)
|
|
|
|
|
2017-03-24 22:33:26 -07:00
|
|
|
add_custom_target(cog ALL DEPENDS ${coggedfiles})
|
2017-03-23 12:06:29 -07:00
|
|
|
|
2017-03-24 22:41:33 -07:00
|
|
|
function(get_sources globtarget output)
|
2017-03-24 22:33:26 -07:00
|
|
|
file(GLOB_RECURSE targetsources RELATIVE "${CMAKE_SOURCE_DIR}"
|
2017-03-24 22:41:33 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/${globtarget}")
|
2017-03-24 22:33:26 -07:00
|
|
|
file(GLOB_RECURSE targetcoggedsources RELATIVE "${CMAKE_SOURCE_DIR}"
|
2017-03-24 22:41:33 -07:00
|
|
|
"${CMAKE_SOURCE_DIR}/${globtarget}.cog")
|
2017-03-24 22:33:26 -07:00
|
|
|
foreach(targetcog ${targetcoggedsources})
|
|
|
|
string(REGEX REPLACE ".cog\$" "" this "${targetcog}")
|
|
|
|
set(targetsources ${targetsources} ${this})
|
|
|
|
endforeach(targetcog)
|
2017-03-23 21:20:26 -07:00
|
|
|
|
2017-03-24 22:41:33 -07:00
|
|
|
set(${output} ${targetsources} PARENT_SCOPE)
|
|
|
|
endfunction(get_sources)
|
|
|
|
|
|
|
|
set(cellar_LIBRARIES)
|
2017-03-28 12:41:25 -07:00
|
|
|
function(cellar_library)
|
|
|
|
set(multiValueArgs SUBDIRS)
|
|
|
|
set(oneValueArgs TARGET)
|
|
|
|
cmake_parse_arguments(cellar_library "" "${oneValueArgs}"
|
|
|
|
"${multiValueArgs}" ${ARGN})
|
|
|
|
|
|
|
|
set(target ${cellar_library_TARGET})
|
|
|
|
|
|
|
|
set(targetsources)
|
|
|
|
foreach(subdir ${cellar_library_SUBDIRS})
|
|
|
|
get_sources("src/${subdir}/*.cpp" subdirsources)
|
|
|
|
|
|
|
|
foreach(source ${subdirsources})
|
|
|
|
set(targetsources ${targetsources} ${source})
|
|
|
|
endforeach(source)
|
|
|
|
endforeach(subdir)
|
2017-03-24 22:41:33 -07:00
|
|
|
|
2017-03-24 22:33:26 -07:00
|
|
|
add_library(${target} SHARED ${targetsources})
|
|
|
|
add_dependencies(${target} cog)
|
|
|
|
|
|
|
|
set(cellar_LIBRARIES ${cellar_LIBRARIES} ${target} PARENT_SCOPE)
|
|
|
|
endfunction(cellar_library)
|
|
|
|
|
2017-04-13 15:02:50 -07:00
|
|
|
cellar_library(TARGET cellarlib SUBDIRS bottles launch config)
|
2017-03-23 01:03:33 -07:00
|
|
|
|
2017-03-24 23:37:49 -07:00
|
|
|
file(GLOB coresources RELATIVE "${CMAKE_SOURCE_DIR}"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/*.cpp")
|
|
|
|
file(GLOB corecoggedsources RELATIVE "${CMAKE_SOURCE_DIR}"
|
|
|
|
"${CMAKE_SOURCE_DIR}/src/*.cpp.cog")
|
|
|
|
foreach(corecog ${corecoggedsources})
|
|
|
|
string(REGEX REPLACE ".cog\$" "" this "${corecog}")
|
|
|
|
set(coresources ${coresources} ${this})
|
|
|
|
endforeach(corecog)
|
|
|
|
|
|
|
|
get_sources("src/help/*.cpp" helpsources)
|
|
|
|
|
|
|
|
add_executable(cellar ${coresources} ${helpsources})
|
2017-03-24 22:33:26 -07:00
|
|
|
target_link_libraries(cellar ${cellar_LIBRARIES} ${Boost_LIBRARIES})
|
2017-03-24 21:50:32 -07:00
|
|
|
add_dependencies(cellar cog) # effectively redundant but a couple of the bin's
|
|
|
|
# files are cogged, so this is mostly for people
|
|
|
|
# looking at CMakeLists.txt for hints
|
2017-03-23 13:36:38 -07:00
|
|
|
|
2017-06-28 19:22:34 -07:00
|
|
|
generate_manpage(cellar 1)
|
|
|
|
add_manpage_target()
|
|
|
|
|
2017-03-24 22:33:26 -07:00
|
|
|
install(TARGETS cellar ${cellar_LIBRARIES}
|
2017-03-23 13:36:38 -07:00
|
|
|
RUNTIME DESTINATION bin
|
|
|
|
LIBRARY DESTINATION lib/cellar
|
|
|
|
ARCHIVE DESTINATION share/cellar)
|