cmake update
This commit is contained in:
parent
429b19abee
commit
a74796f2f3
123
CMakeLists.txt
123
CMakeLists.txt
@ -1,20 +1,11 @@
|
|||||||
cmake_minimum_required(VERSION 3.7.2)
|
cmake_minimum_required(VERSION 3.7.2)
|
||||||
project(cellar CXX)
|
|
||||||
set(CMAKE_CXX_STANDARD 11)
|
|
||||||
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
|
||||||
|
|
||||||
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")
|
|
||||||
|
|
||||||
if(NOT CMAKE_BUILD_TYPE)
|
|
||||||
message(STATUS "Assuming this is a release build. -DCMAKE_BUILD_TYPE=Debug otherwise.")
|
|
||||||
set(CMAKE_BUILD_TYPE "Release")
|
|
||||||
endif(NOT CMAKE_BUILD_TYPE)
|
|
||||||
|
|
||||||
# local cmake modules
|
|
||||||
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules)
|
||||||
|
include(Colours)
|
||||||
|
include(Platform)
|
||||||
|
|
||||||
|
project(cellar CXX)
|
||||||
|
string(TIMESTAMP BUILD_DATE "%Y.%m.%d %H:%M:%S UTC" UTC)
|
||||||
|
# local cmake modules
|
||||||
|
|
||||||
# for installation rules, from CMake wiki
|
# for installation rules, from CMake wiki
|
||||||
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/cellar")
|
SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/cellar")
|
||||||
@ -26,13 +17,16 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE)
|
|||||||
include(Git)
|
include(Git)
|
||||||
git_init()
|
git_init()
|
||||||
|
|
||||||
|
include(Cog)
|
||||||
|
cog_target()
|
||||||
|
|
||||||
include(Ronn)
|
include(Ronn)
|
||||||
|
|
||||||
find_package(PythonInterp)
|
generate_manpage(cellar 1)
|
||||||
find_package(PythonModule)
|
add_manpage_target()
|
||||||
find_python_module(cogapp REQUIRED)
|
|
||||||
|
|
||||||
find_package(Boost 1.63 REQUIRED COMPONENTS filesystem system)
|
find_package(Boost 1.63 REQUIRED COMPONENTS filesystem system)
|
||||||
|
include_directories(${Boost_INCLUDE_DIRS})
|
||||||
|
|
||||||
find_package(PkgConfig)
|
find_package(PkgConfig)
|
||||||
pkg_check_modules(TCLAP "tclap >= 1.2.1")
|
pkg_check_modules(TCLAP "tclap >= 1.2.1")
|
||||||
@ -43,95 +37,24 @@ http://tclap.sourceforge.net and put the headers in ./include
|
|||||||
(wink, nudge)")
|
(wink, nudge)")
|
||||||
endif(NOT TCLAP_FOUND)
|
endif(NOT TCLAP_FOUND)
|
||||||
|
|
||||||
include_directories("${CMAKE_SOURCE_DIR}/include")
|
include(LavaTargets)
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in"
|
configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in"
|
||||||
"${CMAKE_CURRENT_BINARY_DIR}/include/cmake.hpp")
|
"${CMAKE_CURRENT_BINARY_DIR}/include/cmake.hpp")
|
||||||
include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
|
include_directories("${CMAKE_CURRENT_BINARY_DIR}/include")
|
||||||
set(src "${CMAKE_SOURCE_DIR}/src")
|
set(src "${CMAKE_SOURCE_DIR}/src")
|
||||||
|
|
||||||
set(coggedfiles)
|
lava_create_gutlib(
|
||||||
|
SUBDIRS bottles config launch
|
||||||
|
DEPENDS cog)
|
||||||
|
|
||||||
file(GLOB_RECURSE cogfiles RELATIVE "${CMAKE_SOURCE_DIR}"
|
lava_create_executable(TARGET cellar
|
||||||
"${CMAKE_SOURCE_DIR}/*.cog")
|
SUBDIRS core help
|
||||||
|
LIBRARIES gutlib Boost::filesystem Boost::system
|
||||||
|
DEPENDS cog)
|
||||||
|
|
||||||
foreach(cogfile ${cogfiles})
|
install(TARGETS cellar gutlib
|
||||||
# thisfile = absolute path to output file
|
|
||||||
# outfile = relative path
|
|
||||||
# TODO: fix that
|
|
||||||
string(REGEX REPLACE ".cog\$" "" outfile "${cogfile}")
|
|
||||||
set(thisfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
|
|
||||||
|
|
||||||
add_custom_command(OUTPUT "${thisfile}" PRE_BUILD
|
|
||||||
COMMAND ${PYTHON_EXECUTABLE} -m cogapp -d -o "${thisfile}" "${cogfile}"
|
|
||||||
DEPENDS ${cogfile}
|
|
||||||
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
|
||||||
COMMENT "Greasing the cog for ${outfile}")
|
|
||||||
|
|
||||||
set(coggedfiles ${coggedfiles} "${thisfile}")
|
|
||||||
endforeach(cogfile)
|
|
||||||
|
|
||||||
add_custom_target(cog ALL DEPENDS ${coggedfiles})
|
|
||||||
|
|
||||||
function(get_sources globtarget output)
|
|
||||||
file(GLOB_RECURSE targetsources RELATIVE "${CMAKE_SOURCE_DIR}"
|
|
||||||
"${CMAKE_SOURCE_DIR}/${globtarget}")
|
|
||||||
file(GLOB_RECURSE targetcoggedsources RELATIVE "${CMAKE_SOURCE_DIR}"
|
|
||||||
"${CMAKE_SOURCE_DIR}/${globtarget}.cog")
|
|
||||||
foreach(targetcog ${targetcoggedsources})
|
|
||||||
string(REGEX REPLACE ".cog\$" "" this "${targetcog}")
|
|
||||||
set(targetsources ${targetsources} ${this})
|
|
||||||
endforeach(targetcog)
|
|
||||||
|
|
||||||
set(${output} ${targetsources} PARENT_SCOPE)
|
|
||||||
endfunction(get_sources)
|
|
||||||
|
|
||||||
set(cellar_LIBRARIES)
|
|
||||||
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)
|
|
||||||
|
|
||||||
add_library(${target} SHARED ${targetsources})
|
|
||||||
add_dependencies(${target} cog)
|
|
||||||
|
|
||||||
set(cellar_LIBRARIES ${cellar_LIBRARIES} ${target} PARENT_SCOPE)
|
|
||||||
endfunction(cellar_library)
|
|
||||||
|
|
||||||
cellar_library(TARGET cellarlib SUBDIRS bottles launch config)
|
|
||||||
|
|
||||||
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})
|
|
||||||
target_link_libraries(cellar ${cellar_LIBRARIES} ${Boost_LIBRARIES})
|
|
||||||
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
|
|
||||||
|
|
||||||
generate_manpage(cellar 1)
|
|
||||||
add_manpage_target()
|
|
||||||
|
|
||||||
install(TARGETS cellar ${cellar_LIBRARIES}
|
|
||||||
RUNTIME DESTINATION bin
|
RUNTIME DESTINATION bin
|
||||||
LIBRARY DESTINATION lib/cellar
|
LIBRARY DESTINATION lib/cellar
|
||||||
ARCHIVE DESTINATION share/cellar)
|
ARCHIVE DESTINATION share/cellar)
|
||||||
|
43
cmake/Modules/Cog.cmake
Normal file
43
cmake/Modules/Cog.cmake
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
find_package(PythonInterp)
|
||||||
|
find_package(PythonModule)
|
||||||
|
find_python_module(cogapp REQUIRED)
|
||||||
|
|
||||||
|
function(cog_sources globtarget output)
|
||||||
|
file(GLOB_RECURSE targetsources RELATIVE "${CMAKE_SOURCE_DIR}"
|
||||||
|
"${CMAKE_SOURCE_DIR}/${globtarget}")
|
||||||
|
file(GLOB_RECURSE targetcoggedsources RELATIVE "${CMAKE_SOURCE_DIR}"
|
||||||
|
"${CMAKE_SOURCE_DIR}/${globtarget}.cog")
|
||||||
|
foreach(targetcog ${targetcoggedsources})
|
||||||
|
string(REGEX REPLACE ".cog\$" "" this "${targetcog}")
|
||||||
|
set(targetsources ${targetsources} ${this})
|
||||||
|
endforeach(targetcog)
|
||||||
|
|
||||||
|
set(${output} ${targetsources} PARENT_SCOPE)
|
||||||
|
endfunction(cog_sources)
|
||||||
|
|
||||||
|
macro(cog_target)
|
||||||
|
# macro to add target to run cog for ALL files
|
||||||
|
# useful for dependency management
|
||||||
|
set(coggedfiles)
|
||||||
|
|
||||||
|
file(GLOB_RECURSE cogfiles RELATIVE "${CMAKE_SOURCE_DIR}"
|
||||||
|
"${CMAKE_SOURCE_DIR}/*.cog")
|
||||||
|
|
||||||
|
foreach(cogfile ${cogfiles})
|
||||||
|
# thisfile = absolute path to output file
|
||||||
|
# outfile = relative path
|
||||||
|
# TODO: fix that
|
||||||
|
string(REGEX REPLACE ".cog\$" "" outfile "${cogfile}")
|
||||||
|
set(thisfile "${CMAKE_CURRENT_BINARY_DIR}/${outfile}")
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT "${thisfile}" PRE_BUILD
|
||||||
|
COMMAND ${PYTHON_EXECUTABLE} -m cogapp -d -o "${thisfile}" "${cogfile}"
|
||||||
|
DEPENDS ${cogfile}
|
||||||
|
WORKING_DIRECTORY ${CMAKE_SOURCE_DIR}
|
||||||
|
COMMENT "Greasing the cog for ${BoldCyan}${outfile}${ColourReset}")
|
||||||
|
|
||||||
|
set(coggedfiles ${coggedfiles} "${thisfile}")
|
||||||
|
endforeach(cogfile)
|
||||||
|
|
||||||
|
add_custom_target(cog DEPENDS ${coggedfiles})
|
||||||
|
endmacro(cog_target)
|
24
cmake/Modules/Colours.cmake
Normal file
24
cmake/Modules/Colours.cmake
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
# basically an assembled version of https://stackoverflow.com/questions/18968979/how-to-get-colorized-output-with-cmake
|
||||||
|
# spelled with a u because the guy in the answer seemed to insist on it
|
||||||
|
|
||||||
|
if(NOT MSVC)
|
||||||
|
string(ASCII 27 Esc)
|
||||||
|
set(ColourReset "${Esc}[0m")
|
||||||
|
set(ColourBold "${Esc}[1m")
|
||||||
|
set(Red "${Esc}[0;31m")
|
||||||
|
set(Green "${Esc}[0;32m")
|
||||||
|
set(Yellow "${Esc}[0;33m")
|
||||||
|
set(Blue "${Esc}[0;34m")
|
||||||
|
set(Magenta "${Esc}[0;35m")
|
||||||
|
set(Cyan "${Esc}[0;36m")
|
||||||
|
set(White "${Esc}[0;37m")
|
||||||
|
set(BoldRed "${Esc}[1;31m")
|
||||||
|
set(BoldGreen "${Esc}[1;32m")
|
||||||
|
set(BoldYellow "${Esc}[1;33m")
|
||||||
|
set(BoldBlue "${Esc}[1;34m")
|
||||||
|
set(BoldMagenta "${Esc}[1;35m")
|
||||||
|
set(BoldCyan "${Esc}[1;36m")
|
||||||
|
set(BoldWhite "${Esc}[1;37m")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
|
38
cmake/Modules/FindCrypto++.cmake
Normal file
38
cmake/Modules/FindCrypto++.cmake
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
# from https://github.com/harningt/cryptoface
|
||||||
|
# note: that's actually a library for supporting multiple crypto implementations
|
||||||
|
# might consider switching to that
|
||||||
|
# - Find Crypto++
|
||||||
|
|
||||||
|
if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||||
|
set(CRYPTO++_FOUND TRUE)
|
||||||
|
|
||||||
|
else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||||
|
find_path(CRYPTO++_INCLUDE_DIR cryptlib.h
|
||||||
|
/usr/include/crypto++
|
||||||
|
/usr/include/cryptopp
|
||||||
|
/usr/local/include/crypto++
|
||||||
|
/usr/local/include/cryptopp
|
||||||
|
/opt/local/include/crypto++
|
||||||
|
/opt/local/include/cryptopp
|
||||||
|
$ENV{SystemDrive}/Crypto++/include
|
||||||
|
)
|
||||||
|
|
||||||
|
find_library(CRYPTO++_LIBRARIES NAMES cryptopp
|
||||||
|
PATHS
|
||||||
|
/usr/lib
|
||||||
|
/usr/local/lib
|
||||||
|
/opt/local/lib
|
||||||
|
$ENV{SystemDrive}/Crypto++/lib
|
||||||
|
)
|
||||||
|
|
||||||
|
if(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||||
|
set(CRYPTO++_FOUND TRUE)
|
||||||
|
message(STATUS "Found Crypto++: ${CRYPTO++_INCLUDE_DIR}, ${CRYPTO++_LIBRARIES}")
|
||||||
|
else(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||||
|
set(CRYPTO++_FOUND FALSE)
|
||||||
|
message(STATUS "Crypto++ not found.")
|
||||||
|
endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
||||||
|
|
||||||
|
mark_as_advanced(CRYPTO++_INCLUDE_DIR CRYPTO++_LIBRARIES)
|
||||||
|
|
||||||
|
endif(CRYPTO++_INCLUDE_DIR AND CRYPTO++_LIBRARIES)
|
@ -46,7 +46,7 @@ function(git_submodule)
|
|||||||
|
|
||||||
execute_process(COMMAND git submodule update --init -- "${GIT_SUBMODULE_DIR}/${GIT_SUBMODULE_TARGET}"
|
execute_process(COMMAND git submodule update --init -- "${GIT_SUBMODULE_DIR}/${GIT_SUBMODULE_TARGET}"
|
||||||
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
WORKING_DIRECTORY "${CMAKE_SOURCE_DIR}"
|
||||||
COMMENT "Updating submodule ${GIT_SUBMODULE_DIR}/${GIT_SUBMODULE_TARGET}"
|
COMMENT "Updating submodule ${Magenta}${GIT_SUBMODULE_DIR}/${GIT_SUBMODULE_TARGET}${ColourReset}"
|
||||||
VERBATIM)
|
VERBATIM)
|
||||||
endif(IS_GIT_REPO)
|
endif(IS_GIT_REPO)
|
||||||
endfunction(git_submodule)
|
endfunction(git_submodule)
|
||||||
|
94
cmake/Modules/LavaTargets.cmake
Normal file
94
cmake/Modules/LavaTargets.cmake
Normal file
@ -0,0 +1,94 @@
|
|||||||
|
link_directories(${CMAKE_CURRENT_BINARY_DIR})
|
||||||
|
|
||||||
|
function(lava_create_library)
|
||||||
|
set(multiValueArgs SUBDIRS DEPENDS LIBRARIES)
|
||||||
|
set(oneValueArgs TARGET)
|
||||||
|
cmake_parse_arguments(lava_create_library "" "${oneValueArgs}"
|
||||||
|
"${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
set(target ${lava_create_library_TARGET})
|
||||||
|
|
||||||
|
set(targetsources)
|
||||||
|
foreach(subdir ${lava_create_library_SUBDIRS})
|
||||||
|
cog_sources("src/${subdir}/*.cpp" subdirsources)
|
||||||
|
|
||||||
|
foreach(source ${subdirsources})
|
||||||
|
set(targetsources ${targetsources} ${source})
|
||||||
|
endforeach(source)
|
||||||
|
endforeach(subdir)
|
||||||
|
|
||||||
|
add_library(${target} SHARED ${targetsources})
|
||||||
|
if(MINGW)
|
||||||
|
# MinGW (or CMake?) does a stupid, redundant thing where it names all output DLLs
|
||||||
|
# "libblah.dll" and it's kinda stupid and redundant
|
||||||
|
# this removes the "lib" prefix because removing ".dll" causes things to break
|
||||||
|
set_target_properties(${target} PROPERTIES PREFIX "")
|
||||||
|
endif()
|
||||||
|
if(lava_create_library_LIBRARIES)
|
||||||
|
foreach(library ${lava_create_library_LIBRARIES})
|
||||||
|
target_link_libraries(${target} "${library}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
if(lava_create_library_DEPENDS)
|
||||||
|
add_dependencies(${target} ${lava_create_library_DEPENDS})
|
||||||
|
endif()
|
||||||
|
endfunction(lava_create_library)
|
||||||
|
|
||||||
|
function(lava_create_gutlib)
|
||||||
|
set(multiValueArgs SUBDIRS DEPENDS LIBRARIES LIBRARYVARS)
|
||||||
|
cmake_parse_arguments(lava_create_gutlib "" ""
|
||||||
|
"${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
foreach(subdir ${lava_create_gutlib_SUBDIRS})
|
||||||
|
cog_sources("src/${subdir}/*.cpp" subdirsources)
|
||||||
|
|
||||||
|
foreach(source ${subdirsources})
|
||||||
|
set(targetsources ${targetsources} ${source})
|
||||||
|
endforeach(source)
|
||||||
|
endforeach(subdir)
|
||||||
|
|
||||||
|
add_library(gutlib SHARED ${targetsources})
|
||||||
|
set_target_properties(gutlib PROPERTIES OUTPUT_NAME ${CMAKE_PROJECT_NAME})
|
||||||
|
if(MINGW)
|
||||||
|
# MinGW (or CMake?) does a stupid, redundant thing where it names all output DLLs
|
||||||
|
# "libblah.dll" and it's kinda stupid and redundant
|
||||||
|
# this removes the "lib" prefix because removing ".dll" causes things to break
|
||||||
|
set_target_properties(gutlib PROPERTIES PREFIX "")
|
||||||
|
endif()
|
||||||
|
if(lava_create_gutlib_LIBRARIES)
|
||||||
|
foreach(library ${lava_create_gutlib_LIBRARIES})
|
||||||
|
target_link_libraries(gutlib "${library}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
if(lava_create_gutlib_DEPENDS)
|
||||||
|
add_dependencies(gutlib ${lava_create_gutlib_DEPENDS})
|
||||||
|
endif()
|
||||||
|
endfunction(lava_create_gutlib)
|
||||||
|
|
||||||
|
function(lava_create_executable)
|
||||||
|
set(multiValueArgs SUBDIRS LIBRARIES DEPENDS)
|
||||||
|
set(oneValueArgs TARGET)
|
||||||
|
cmake_parse_arguments(lava_create_executable "" "${oneValueArgs}"
|
||||||
|
"${multiValueArgs}" ${ARGN})
|
||||||
|
|
||||||
|
set(target ${lava_create_executable_TARGET})
|
||||||
|
|
||||||
|
set(targetsources)
|
||||||
|
foreach(subdir ${lava_create_executable_SUBDIRS})
|
||||||
|
cog_sources("src/${subdir}/*.cpp" subdirsources)
|
||||||
|
|
||||||
|
foreach(source ${subdirsources})
|
||||||
|
set(targetsources ${targetsources} ${source})
|
||||||
|
endforeach(source)
|
||||||
|
endforeach(subdir)
|
||||||
|
|
||||||
|
add_executable(${target} ${targetsources})
|
||||||
|
if(lava_create_executable_LIBRARIES)
|
||||||
|
foreach(library ${lava_create_executable_LIBRARIES})
|
||||||
|
target_link_libraries(${target} "${library}")
|
||||||
|
endforeach()
|
||||||
|
endif()
|
||||||
|
if(lava_create_executable_DEPENDS)
|
||||||
|
add_dependencies(${target} ${lava_create_executable_DEPENDS})
|
||||||
|
endif()
|
||||||
|
endfunction(lava_create_executable)
|
47
cmake/Modules/Platform.cmake
Normal file
47
cmake/Modules/Platform.cmake
Normal file
@ -0,0 +1,47 @@
|
|||||||
|
set(CMAKE_CXX_STANDARD 11)
|
||||||
|
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
||||||
|
|
||||||
|
set(PLATFORM_FOREIGN_ENV FALSE)
|
||||||
|
|
||||||
|
if(WIN32)
|
||||||
|
set(PLATFORM_WINDOWS TRUE)
|
||||||
|
else()
|
||||||
|
set(PLATFORM_WINDOWS FALSE)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
set(PLATFORM_WINDOWS TRUE)
|
||||||
|
set(PLATFORM_FOREIGN_ENV TRUE)
|
||||||
|
else()
|
||||||
|
set(CMAKE_CXX_FLAGS "-pipe ${CMAKE_CXX_FLAGS}")
|
||||||
|
set(CMAKE_CXX_FLAGS_DEBUG "-O0 -g -Wall")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELEASE "-O2")
|
||||||
|
set(CMAKE_CXX_FLAGS_RELWITHDBGINFO "${CMAKE_CXX_FLAGS_RELEASE} -g")
|
||||||
|
|
||||||
|
if(MINGW OR MSYS)
|
||||||
|
set(PLATFORM_WINDOWS TRUE)
|
||||||
|
string(APPEND CMAKE_CXX_FLAGS " -mwin32 -Wl,-subsystem,windows")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(CYGWIN)
|
||||||
|
set(PLATFORM_FOREIGN_ENV TRUE)
|
||||||
|
endif()
|
||||||
|
endif(CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
|
||||||
|
|
||||||
|
if(NOT CMAKE_BUILD_TYPE)
|
||||||
|
message(STATUS "${BoldGreen}Assuming this is a release build. ${BoldYellow}-DCMAKE_BUILD_TYPE=Debug${Green} otherwise.${ColourReset}")
|
||||||
|
set(CMAKE_BUILD_TYPE Release)
|
||||||
|
endif(NOT CMAKE_BUILD_TYPE)
|
||||||
|
|
||||||
|
if(PLATFORM_WINDOWS)
|
||||||
|
message(STATUS "Compiling for Windows - good luck, commander.
|
||||||
|
Remember to track down and bundle any DLLs you may need.")
|
||||||
|
set(PLATFORM_TYPE win32)
|
||||||
|
else()
|
||||||
|
set(PLATFORM_TYPE linux)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(PLATFORM_FOREIGN_ENV)
|
||||||
|
message(WARNING "${Yellow}This is an unfamiliar build environment.${ColourReset} Tread carefully and expect failure.
|
||||||
|
If you manage to get it working I'd love to hear about it.")
|
||||||
|
endif()
|
68
cmake/Modules/Qt.cmake
Normal file
68
cmake/Modules/Qt.cmake
Normal file
@ -0,0 +1,68 @@
|
|||||||
|
find_package(Qt5 REQUIRED COMPONENTS Core Widgets)
|
||||||
|
include_directories(${Qt5_INCLUDES} ${Qt5_DIR})
|
||||||
|
|
||||||
|
file(READ "${CMAKE_SOURCE_DIR}/res/moc.txt" moclist)
|
||||||
|
string(REGEX REPLACE "\n" ";" moclist ${moclist}) # split into array by line
|
||||||
|
|
||||||
|
# note: i am aware of the existence of qt5_wrap_cpp and friends, but those functions
|
||||||
|
# aren't aware of my code generator so i have to do it myself
|
||||||
|
# also, qt5_wrap_ui just dumps headers in the root of the build dir. ew.
|
||||||
|
|
||||||
|
if(NOT QT_UIC_EXECUTABLE)
|
||||||
|
string(REPLACE moc uic QT_UIC_EXECUTABLE "${QT_MOC_EXECUTABLE}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(mocsources)
|
||||||
|
set(qtcogged FALSE)
|
||||||
|
if(NOT EXISTS "${CMAKE_CURRENT_BINARY_DIR}/src/qtgenerated")
|
||||||
|
file(MAKE_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/src/qtgenerated")
|
||||||
|
endif()
|
||||||
|
foreach(mocfile ${moclist})
|
||||||
|
if(EXISTS ${CMAKE_SOURCE_DIR}/${mocfile})
|
||||||
|
string(REGEX REPLACE ".h\$" ".cpp" implfile_rel "${mocfile}")
|
||||||
|
string(REGEX REPLACE "include/" "src/qtgenerated/moc_" implfile_rel "${implfile_rel}")
|
||||||
|
set(implfile_abs "${CMAKE_CURRENT_BINARY_DIR}/${implfile_rel}")
|
||||||
|
add_custom_command(OUTPUT "${implfile_abs}" PRE_BUILD
|
||||||
|
COMMAND ${QT_MOC_EXECUTABLE} -o "${implfile_abs}" "${CMAKE_SOURCE_DIR}/${mocfile}"
|
||||||
|
DEPENDS "${CMAKE_SOURCE_DIR}/${mocfile}"
|
||||||
|
COMMENT "Qt MOC: ${BoldCyan}${mocfile}${ColourReset}")
|
||||||
|
elseif(EXISTS ${CMAKE_SOURCE_DIR}/${mocfile}.cog)
|
||||||
|
set(qtcogged TRUE)
|
||||||
|
string(REGEX REPLACE ".h\$" ".cpp" implfile_rel "${mocfile}")
|
||||||
|
string(REGEX REPLACE "include/" "src/qtgenerated/moc_" implfile_rel "${implfile_rel}")
|
||||||
|
set(implfile_abs "${CMAKE_CURRENT_BINARY_DIR}/${implfile_rel}")
|
||||||
|
add_custom_command(OUTPUT "${implfile_abs}" PRE_BUILD
|
||||||
|
COMMAND ${QT_MOC_EXECUTABLE} -o "${implfile_abs}" "${CMAKE_CURRENT_BINARY_DIR}/${mocfile}"
|
||||||
|
DEPENDS "${CMAKE_CURRENT_BINARY_DIR}/${mocfile}"
|
||||||
|
COMMENT "Qt MOC: ${BoldCyan}${mocfile}${ColourReset}")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
set(mocsources ${mocsources} "${implfile_abs}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
file(GLOB_RECURSE uilist RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/res/ui/*.ui")
|
||||||
|
set(uicsources)
|
||||||
|
foreach(uifile ${uilist})
|
||||||
|
string(REGEX REPLACE "res/ui/" "" uiname ${uifile})
|
||||||
|
string(REGEX REPLACE ".ui\$" "" uiname ${uiname})
|
||||||
|
string(REGEX REPLACE "/" "_" uiname ${uiname})
|
||||||
|
# res/ui/dlg/license.ui should result in ${uiname} being "dlg_license" at this point
|
||||||
|
|
||||||
|
set(headerfile "${CMAKE_CURRENT_BINARY_DIR}/include/ui_${uiname}.h")
|
||||||
|
|
||||||
|
add_custom_command(OUTPUT "${headerfile}" PRE_BUILD
|
||||||
|
# TODO: not hardcode this path
|
||||||
|
COMMAND ${QT_UIC_EXECUTABLE} -o "${headerfile}" "${CMAKE_SOURCE_DIR}/${uifile}"
|
||||||
|
DEPENDS "${CMAKE_SOURCE_DIR}/${uifile}"
|
||||||
|
COMMENT "Qt UIC: ${BoldCyan}${uifile}${ColourReset}")
|
||||||
|
|
||||||
|
set(uicsources ${uicsources} "${headerfile}")
|
||||||
|
endforeach()
|
||||||
|
|
||||||
|
add_library(qtgenerated STATIC ${mocsources} ${uicsources})
|
||||||
|
target_link_libraries(qtgenerated Qt5::Core Qt5::Widgets)
|
||||||
|
if (qtcogged)
|
||||||
|
add_dependencies(qtgenerated cog)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
message(STATUS "Found Qt: ${Qt5_VERSION}")
|
@ -2,7 +2,7 @@ find_program(RONN ronn)
|
|||||||
find_program(GZIP gzip)
|
find_program(GZIP gzip)
|
||||||
|
|
||||||
if(NOT RONN OR NOT GZIP)
|
if(NOT RONN OR NOT GZIP)
|
||||||
message(WARNING "Not generating manpages")
|
message(WARNING "${BoldYellow}Not generating manpages${ColourReset}")
|
||||||
if(NOT RONN)
|
if(NOT RONN)
|
||||||
message(WARNING " ronn not installed")
|
message(WARNING " ronn not installed")
|
||||||
endif(NOT RONN)
|
endif(NOT RONN)
|
||||||
|
37
cmake/Modules/Sphinx.cmake
Normal file
37
cmake/Modules/Sphinx.cmake
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
find_program(DVIPNG dvipng)
|
||||||
|
find_program(DVISVGM dvisvgm)
|
||||||
|
find_program(SPHINX_BUILD sphinx-build)
|
||||||
|
|
||||||
|
if(NOT DOCS_TOO)
|
||||||
|
set(DOCS_TOO 0)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if(NOT DVIPNG OR NOT DVISVGM OR NOT SPHINX_BUILD)
|
||||||
|
message(WARNING "${BoldYellow}Cannot build library documentation.${ColourReset}")
|
||||||
|
|
||||||
|
# report what's missing
|
||||||
|
if(NOT DVIPNG)
|
||||||
|
message(WARNING " dvipng not installed.")
|
||||||
|
endif()
|
||||||
|
if(NOT DVISVGM)
|
||||||
|
message(WARNING " dvisvgm not installed.")
|
||||||
|
endif()
|
||||||
|
if(NOT SPHINX_BUILD)
|
||||||
|
message(WARNING " Sphinx not installed.")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
if (DOCS_TOO EQUAL 1)
|
||||||
|
message(FATAL_ERROR "${BoldRed}This is a problem, since you specified DOCS_TOO.${ColourReset}")
|
||||||
|
endif()
|
||||||
|
else()
|
||||||
|
if(DOCS_TOO EQUAL 1)
|
||||||
|
set(MAYBE_ALL ALL)
|
||||||
|
else()
|
||||||
|
message(STATUS "${Green}Not building docs automatically. Build them with: ${BoldGreen}${CMAKE_MAKE_PROGRAM} sphinx${ColourReset}
|
||||||
|
An alternative strategy would be to run CMake again with ${BoldYellow}-DDOCS_TOO=1${ColourReset}")
|
||||||
|
set(MAYBE_ALL "")
|
||||||
|
endif()
|
||||||
|
|
||||||
|
add_custom_target(sphinx ${MAYBE_ALL}
|
||||||
|
COMMAND ${SPHINX_BUILD} -b html "${CMAKE_SOURCE_DIR}/doc/sphinx" "${CMAKE_CURRENT_BINARY_DIR}/doc")
|
||||||
|
endif()
|
@ -1,28 +0,0 @@
|
|||||||
// vim: ft=cpp :
|
|
||||||
|
|
||||||
#include "nlohmann/json.hpp"
|
|
||||||
|
|
||||||
#include "config.hpp"
|
|
||||||
|
|
||||||
using namespace std;
|
|
||||||
using nlohmann::json;
|
|
||||||
|
|
||||||
json cellar::config::get_default_config() {
|
|
||||||
json result;
|
|
||||||
/*[[[cog
|
|
||||||
import cog
|
|
||||||
import configparser
|
|
||||||
|
|
||||||
cparse = configparser.ConfigParser()
|
|
||||||
cparse.read("cogrc")
|
|
||||||
config = cparse["defaults"]
|
|
||||||
for key in config.keys(): # TODO: bug #26
|
|
||||||
value = config[key]
|
|
||||||
print(" -- Compiling in default value for {0}: {1}".format(key, value))
|
|
||||||
cog.outl("result[\"{0}\"] = \"{1}\";".format(key, value))
|
|
||||||
]]]*/
|
|
||||||
//[[[end]]]
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
@ -111,13 +111,9 @@ int main(int argc, char* argv[]) {
|
|||||||
output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
|
output::warning("your shell didn't expand your given path properly, doing a naive replacement", true);
|
||||||
bottles::active_bottle = bottles::Bottle(bottlechoice);
|
bottles::active_bottle = bottles::Bottle(bottlechoice);
|
||||||
} else {
|
} else {
|
||||||
if (bottlechoice.substr(0,6) == ".wine.") {
|
|
||||||
output::statement("tip: cellar can add the \".wine.\" prefix automatically");
|
|
||||||
bottlechoice.replace(0,6,"");
|
|
||||||
}
|
|
||||||
|
|
||||||
string homepath = getenv("HOME");
|
string homepath = getenv("HOME");
|
||||||
string fullbottlepath = homepath + "/.wine." + bottlechoice;
|
string fullbottlepath = homepath + "/.local/share/cellar/bottles/" + bottlechoice;
|
||||||
bottles::active_bottle = bottles::Bottle(fullbottlepath);
|
bottles::active_bottle = bottles::Bottle(fullbottlepath);
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user