initial commit
This commit is contained in:
commit
31c56d972c
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
build/**
|
39
CMakeLists.txt
Normal file
39
CMakeLists.txt
Normal file
@ -0,0 +1,39 @@
|
|||||||
|
cmake_minimum_required(VERSION 3.16)
|
||||||
|
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_SOURCE_DIR}/cmake)
|
||||||
|
|
||||||
|
include(Colours)
|
||||||
|
include(Binaries)
|
||||||
|
|
||||||
|
project(bootlatch VERSION 0.1)
|
||||||
|
string(TIMESTAMP BUILD_TIME)
|
||||||
|
|
||||||
|
execute_process(COMMAND conan install ${CMAKE_SOURCE_DIR} --output-folder=${CMAKE_BINARY_DIR} --build missing)
|
||||||
|
|
||||||
|
include(${CMAKE_BINARY_DIR}/conan_toolchain.cmake)
|
||||||
|
|
||||||
|
set(CMAKE_CXX_STANDARD 17)
|
||||||
|
|
||||||
|
# nlohmann/json
|
||||||
|
find_package(nlohmann_json)
|
||||||
|
include_directories(${nlohmann_json_INCLUDE_DIR})
|
||||||
|
|
||||||
|
include_directories(include)
|
||||||
|
include_directories(ext_include)
|
||||||
|
include_directories(${CMAKE_BINARY_DIR}/include)
|
||||||
|
|
||||||
|
# docs
|
||||||
|
find_package(Doxygen)
|
||||||
|
if (DOXYGEN_FOUND)
|
||||||
|
configure_file(${CMAKE_SOURCE_DIR}/doc/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY)
|
||||||
|
|
||||||
|
add_custom_target(doc
|
||||||
|
COMMAND ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
|
||||||
|
WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
|
||||||
|
COMMENT "Generating documentation with doxygen"
|
||||||
|
VERBATIM)
|
||||||
|
endif()
|
||||||
|
|
||||||
|
build_executable(TARGET bootlatch
|
||||||
|
SUBDIRS bootlatch)
|
||||||
|
|
||||||
|
install(TARGETS bootlatch RUNTIME)
|
80
cmake/Binaries.cmake
Normal file
80
cmake/Binaries.cmake
Normal file
@ -0,0 +1,80 @@
|
|||||||
|
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")
|
||||||
|
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")
|
||||||
|
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()
|
24
cmake/Colours.cmake
Normal file
24
cmake/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()
|
||||||
|
|
||||||
|
|
37
cmake/Qt.cmake
Normal file
37
cmake/Qt.cmake
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
set(QT_VERSION_STR "5.15.2")
|
||||||
|
set(CMAKE_PREFIX_PATH "C:\\Qt\\${QT_VERSION_STR}\\msvc2019_64")
|
||||||
|
find_package(Qt5 COMPONENTS Core Widgets REQUIRED)
|
||||||
|
set(QT_UIC_EXECUTABLE "C:\\Qt\\${QT_VERSION_STR}\\msvc2019_64\\bin\\uic.exe")
|
||||||
|
|
||||||
|
file(STRINGS "${CMAKE_SOURCE_DIR}/res/moc.txt" mocfiles)
|
||||||
|
|
||||||
|
set(mocdeps)
|
||||||
|
|
||||||
|
foreach(moctgt ${mocfiles})
|
||||||
|
string(REPLACE "include/" "include/moc/" outfile ${moctgt})
|
||||||
|
add_custom_command(OUTPUT "${CMAKE_CURRENT_BINARY_DIR}/${outfile}"
|
||||||
|
COMMAND moc ${CMAKE_SOURCE_DIR}/${moctgt} -o ${CMAKE_CURRENT_BINARY_DIR}/${outfile}
|
||||||
|
COMMENT "Running moc for ${outfile}..."
|
||||||
|
DEPENDS "${CMAKE_SOURCE_DIR}/${moctgt}")
|
||||||
|
set (mocdeps ${mocdeps} ${outfile})
|
||||||
|
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
|
||||||
|
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_custom_target(qtgenerated DEPENDS ${mocdeps} ${uicsources})
|
6
conanfile.txt
Normal file
6
conanfile.txt
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[requires]
|
||||||
|
nlohmann_json/3.11.2
|
||||||
|
|
||||||
|
[generators]
|
||||||
|
CMakeDeps
|
||||||
|
CMakeToolchain
|
6
src/bootlatch/bootlatch.cpp
Normal file
6
src/bootlatch/bootlatch.cpp
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
int main(int argc, char* argv[]) {
|
||||||
|
std::cout << "It works!" << std::endl;
|
||||||
|
return 0;
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user