From a74796f2f326a92723346701fcd2991f141602bf Mon Sep 17 00:00:00 2001 From: Nicholas O'Connor Date: Tue, 13 Mar 2018 20:30:47 -0700 Subject: [PATCH] cmake update --- CMakeLists.txt | 123 ++++++------------------------- cmake/Modules/Cog.cmake | 43 +++++++++++ cmake/Modules/Colours.cmake | 24 ++++++ cmake/Modules/FindCrypto++.cmake | 38 ++++++++++ cmake/Modules/Git.cmake | 2 +- cmake/Modules/LavaTargets.cmake | 94 +++++++++++++++++++++++ cmake/Modules/Platform.cmake | 47 ++++++++++++ cmake/Modules/Qt.cmake | 68 +++++++++++++++++ cmake/Modules/Ronn.cmake | 2 +- cmake/Modules/Sphinx.cmake | 37 ++++++++++ src/config/defaults.cpp.cog | 28 ------- src/{ => core}/cellar.cpp.cog | 6 +- src/{ => core}/commands.cpp.cog | 0 src/{ => core}/fs.cpp | 0 src/{ => core}/output.cpp | 0 src/{ => core}/version.cpp.cog | 0 16 files changed, 377 insertions(+), 135 deletions(-) create mode 100644 cmake/Modules/Cog.cmake create mode 100644 cmake/Modules/Colours.cmake create mode 100644 cmake/Modules/FindCrypto++.cmake create mode 100644 cmake/Modules/LavaTargets.cmake create mode 100644 cmake/Modules/Platform.cmake create mode 100644 cmake/Modules/Qt.cmake create mode 100644 cmake/Modules/Sphinx.cmake delete mode 100644 src/config/defaults.cpp.cog rename src/{ => core}/cellar.cpp.cog (94%) rename src/{ => core}/commands.cpp.cog (100%) rename src/{ => core}/fs.cpp (100%) rename src/{ => core}/output.cpp (100%) rename src/{ => core}/version.cpp.cog (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index d14faa7..38ca889 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,20 +1,11 @@ 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) +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 SET(CMAKE_INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib/cellar") @@ -26,13 +17,16 @@ SET(CMAKE_INSTALL_RPATH_USE_LINK_PATH TRUE) include(Git) git_init() +include(Cog) +cog_target() + include(Ronn) -find_package(PythonInterp) -find_package(PythonModule) -find_python_module(cogapp REQUIRED) +generate_manpage(cellar 1) +add_manpage_target() find_package(Boost 1.63 REQUIRED COMPONENTS filesystem system) +include_directories(${Boost_INCLUDE_DIRS}) find_package(PkgConfig) pkg_check_modules(TCLAP "tclap >= 1.2.1") @@ -43,95 +37,24 @@ http://tclap.sourceforge.net and put the headers in ./include (wink, nudge)") endif(NOT TCLAP_FOUND) -include_directories("${CMAKE_SOURCE_DIR}/include") +include(LavaTargets) + +include_directories(include) configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in" "${CMAKE_CURRENT_BINARY_DIR}/include/cmake.hpp") include_directories("${CMAKE_CURRENT_BINARY_DIR}/include") 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}" - "${CMAKE_SOURCE_DIR}/*.cog") +lava_create_executable(TARGET cellar + SUBDIRS core help + LIBRARIES gutlib Boost::filesystem Boost::system + DEPENDS 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 ${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} +install(TARGETS cellar gutlib RUNTIME DESTINATION bin LIBRARY DESTINATION lib/cellar ARCHIVE DESTINATION share/cellar) diff --git a/cmake/Modules/Cog.cmake b/cmake/Modules/Cog.cmake new file mode 100644 index 0000000..702da32 --- /dev/null +++ b/cmake/Modules/Cog.cmake @@ -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) diff --git a/cmake/Modules/Colours.cmake b/cmake/Modules/Colours.cmake new file mode 100644 index 0000000..3b65485 --- /dev/null +++ b/cmake/Modules/Colours.cmake @@ -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() + + diff --git a/cmake/Modules/FindCrypto++.cmake b/cmake/Modules/FindCrypto++.cmake new file mode 100644 index 0000000..84a07d7 --- /dev/null +++ b/cmake/Modules/FindCrypto++.cmake @@ -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) diff --git a/cmake/Modules/Git.cmake b/cmake/Modules/Git.cmake index 702c1ea..e923840 100644 --- a/cmake/Modules/Git.cmake +++ b/cmake/Modules/Git.cmake @@ -46,7 +46,7 @@ function(git_submodule) execute_process(COMMAND git submodule update --init -- "${GIT_SUBMODULE_DIR}/${GIT_SUBMODULE_TARGET}" 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) endif(IS_GIT_REPO) endfunction(git_submodule) diff --git a/cmake/Modules/LavaTargets.cmake b/cmake/Modules/LavaTargets.cmake new file mode 100644 index 0000000..34a4132 --- /dev/null +++ b/cmake/Modules/LavaTargets.cmake @@ -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) diff --git a/cmake/Modules/Platform.cmake b/cmake/Modules/Platform.cmake new file mode 100644 index 0000000..8593226 --- /dev/null +++ b/cmake/Modules/Platform.cmake @@ -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() diff --git a/cmake/Modules/Qt.cmake b/cmake/Modules/Qt.cmake new file mode 100644 index 0000000..f4ff4d5 --- /dev/null +++ b/cmake/Modules/Qt.cmake @@ -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}") diff --git a/cmake/Modules/Ronn.cmake b/cmake/Modules/Ronn.cmake index b40b176..6c3dbc5 100644 --- a/cmake/Modules/Ronn.cmake +++ b/cmake/Modules/Ronn.cmake @@ -2,7 +2,7 @@ find_program(RONN ronn) find_program(GZIP gzip) if(NOT RONN OR NOT GZIP) - message(WARNING "Not generating manpages") + message(WARNING "${BoldYellow}Not generating manpages${ColourReset}") if(NOT RONN) message(WARNING " ronn not installed") endif(NOT RONN) diff --git a/cmake/Modules/Sphinx.cmake b/cmake/Modules/Sphinx.cmake new file mode 100644 index 0000000..02dc966 --- /dev/null +++ b/cmake/Modules/Sphinx.cmake @@ -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() diff --git a/src/config/defaults.cpp.cog b/src/config/defaults.cpp.cog deleted file mode 100644 index 20194c0..0000000 --- a/src/config/defaults.cpp.cog +++ /dev/null @@ -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; -} - - diff --git a/src/cellar.cpp.cog b/src/core/cellar.cpp.cog similarity index 94% rename from src/cellar.cpp.cog rename to src/core/cellar.cpp.cog index b1bfba4..85a9c00 100644 --- a/src/cellar.cpp.cog +++ b/src/core/cellar.cpp.cog @@ -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); bottles::active_bottle = bottles::Bottle(bottlechoice); } 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 fullbottlepath = homepath + "/.wine." + bottlechoice; + string fullbottlepath = homepath + "/.local/share/cellar/bottles/" + bottlechoice; bottles::active_bottle = bottles::Bottle(fullbottlepath); } } diff --git a/src/commands.cpp.cog b/src/core/commands.cpp.cog similarity index 100% rename from src/commands.cpp.cog rename to src/core/commands.cpp.cog diff --git a/src/fs.cpp b/src/core/fs.cpp similarity index 100% rename from src/fs.cpp rename to src/core/fs.cpp diff --git a/src/output.cpp b/src/core/output.cpp similarity index 100% rename from src/output.cpp rename to src/core/output.cpp diff --git a/src/version.cpp.cog b/src/core/version.cpp.cog similarity index 100% rename from src/version.cpp.cog rename to src/core/version.cpp.cog