diff --git a/CMakeLists.txt b/CMakeLists.txt index 0fec1b1..4dde1e7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.7.2) -set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake/Modules) +set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake) include(Colours) include(Platform) @@ -37,7 +37,8 @@ http://tclap.sourceforge.net and put the headers in ./include (wink, nudge)") endif(NOT TCLAP_FOUND) -include(LavaTargets) +#include(LavaTargets) +include(Binaries) include_directories(include) configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in" @@ -45,16 +46,17 @@ configure_file("${CMAKE_SOURCE_DIR}/include/cmake.hpp.in" include_directories("${CMAKE_CURRENT_BINARY_DIR}/include") set(src "${CMAKE_SOURCE_DIR}/src") -lava_create_gutlib( +build_library(TARGET libcellar SUBDIRS bottles config launch paths DEPENDS cog) +set_target_properties(libcellar PROPERTIES PREFIX "") -lava_create_executable(TARGET cellar +build_executable(TARGET cellar SUBDIRS core help - LIBRARIES gutlib Boost::filesystem Boost::system + LIBRARIES libcellar Boost::filesystem Boost::system DEPENDS cog) -install(TARGETS cellar gutlib +install(TARGETS cellar libcellar RUNTIME DESTINATION bin LIBRARY DESTINATION lib/cellar ARCHIVE DESTINATION share/cellar) diff --git a/cmake/Binaries.cmake b/cmake/Binaries.cmake new file mode 100755 index 0000000..35641c5 --- /dev/null +++ b/cmake/Binaries.cmake @@ -0,0 +1,82 @@ +include(GenerateExportHeader) + +link_directories(${CMAKE_CURRENT_BINARY_DIR}) +set(BUILD_SHARED_LIBS ON) +if (MSVC) + add_compile_options("/utf-8") +endif() + +function(build_library) + set(multiValueArgs SUBDIRS DEPENDS LIBRARIES) + set(oneValueArgs TARGET) + cmake_parse_arguments(build_library "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(target ${build_library_TARGET}) + set(targetsources) + foreach(subdir ${build_library_SUBDIRS}) + set(found_files) + #file(GLOB_RECURSE found_files RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/src/${subdir}/*.cpp") + cog_sources("src/${subdir}/*.cpp" found_files) + set(targetsources ${targetsources} ${found_files}) + endforeach() + + if (MSVC AND EXISTS "${CMAKE_SOURCE_DIR}/res/${target}.rc") + set(targetsources ${targetsources} "res/${target}.rc") + endif() + + add_library(${target} SHARED ${targetsources}) + if (MSVC) + set_target_properties(${target} PROPERTIES PREFIX "") + set_target_properties(${target} PROPERTIES LINK_FLAGS "/MAP") + GENERATE_EXPORT_HEADER(${target} + BASE_NAME ${target} + EXPORT_MACRO_NAME ${target}_EXPORT + EXPORT_FILE_NAME include/${target}_Export.h + STATIC_DEFINE ${target}_BUILT_AS_STATIC) + endif() + + if (build_library_LIBRARIES) + foreach (library ${build_library_LIBRARIES}) + target_link_libraries(${target} ${library}) + endforeach() + endif() + + if (build_library_DEPENDS) + add_dependencies(${target} ${build_library_DEPENDS}) + endif() +endfunction() + +function(build_executable) + set(multiValueArgs SUBDIRS DEPENDS LIBRARIES) + set(oneValueArgs TARGET) + cmake_parse_arguments(build_executable "" "${oneValueArgs}" "${multiValueArgs}" ${ARGN}) + + set(target ${build_executable_TARGET}) + set(targetsources) + foreach(subdir ${build_executable_SUBDIRS}) + set(found_files) + #file(GLOB_RECURSE found_files RELATIVE "${CMAKE_SOURCE_DIR}" "${CMAKE_SOURCE_DIR}/src/${subdir}/*.cpp") + cog_sources("src/${subdir}/*.cpp" found_files) + set(targetsources ${targetsources} ${found_files}) + endforeach() + + if (MSVC AND EXISTS "${CMAKE_SOURCE_DIR}/res/${target}.rc") + set(targetsources ${targetsources} "res/${target}.rc") + endif() + + add_executable(${target} ${targetsources}) + if (MSVC) + # tells MSVC to use int main() but still hide the console window + set_target_properties(${target} PROPERTIES LINK_FLAGS "/SUBSYSTEM:windows /ENTRY:mainCRTStartup") + endif() + + if (build_executable_LIBRARIES) + foreach (library ${build_executable_LIBRARIES}) + target_link_libraries(${target} ${library}) + endforeach() + endif() + + if (build_executable_DEPENDS) + add_dependencies(${target} ${build_executable_DEPENDS}) + endif() +endfunction() \ No newline at end of file diff --git a/cmake/Modules/Cog.cmake b/cmake/Cog.cmake similarity index 100% rename from cmake/Modules/Cog.cmake rename to cmake/Cog.cmake diff --git a/cmake/Modules/Colours.cmake b/cmake/Colours.cmake similarity index 100% rename from cmake/Modules/Colours.cmake rename to cmake/Colours.cmake diff --git a/cmake/Modules/FindCrypto++.cmake b/cmake/FindCrypto++.cmake similarity index 100% rename from cmake/Modules/FindCrypto++.cmake rename to cmake/FindCrypto++.cmake diff --git a/cmake/Modules/FindPythonModule.cmake b/cmake/FindPythonModule.cmake similarity index 100% rename from cmake/Modules/FindPythonModule.cmake rename to cmake/FindPythonModule.cmake diff --git a/cmake/Modules/Git.cmake b/cmake/Git.cmake similarity index 100% rename from cmake/Modules/Git.cmake rename to cmake/Git.cmake diff --git a/cmake/Modules/LavaTargets.cmake b/cmake/LavaTargets.cmake similarity index 100% rename from cmake/Modules/LavaTargets.cmake rename to cmake/LavaTargets.cmake diff --git a/cmake/Modules/Platform.cmake b/cmake/Platform.cmake similarity index 98% rename from cmake/Modules/Platform.cmake rename to cmake/Platform.cmake index 8593226..3bd3ca7 100644 --- a/cmake/Modules/Platform.cmake +++ b/cmake/Platform.cmake @@ -1,4 +1,4 @@ -set(CMAKE_CXX_STANDARD 11) +set(CMAKE_CXX_STANDARD 14) set(CMAKE_CXX_STANDARD_REQUIRED ON) set(PLATFORM_FOREIGN_ENV FALSE) diff --git a/cmake/Modules/Qt.cmake b/cmake/Qt.cmake similarity index 100% rename from cmake/Modules/Qt.cmake rename to cmake/Qt.cmake diff --git a/cmake/Modules/Ronn.cmake b/cmake/Ronn.cmake similarity index 100% rename from cmake/Modules/Ronn.cmake rename to cmake/Ronn.cmake diff --git a/cmake/Modules/Sphinx.cmake b/cmake/Sphinx.cmake similarity index 100% rename from cmake/Modules/Sphinx.cmake rename to cmake/Sphinx.cmake