Giter VIP home page Giter VIP logo

ucmakeskeleton's Introduction

UCMakeSkeleton

Universal simple skeleton of project's tree, based on CMake build system.

Stucture

[ PROJECT ]
ㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤ|- test
ㅤㅤㅤ|- lib
ㅤㅤㅤㅤㅤㅤ|- [ somelib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test
ㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- thirdparty
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- [ thirdlib ]
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- CMakeLists.txt
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- include
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- src
ㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤㅤ|- test

Features

  • automatically applies name of directory as name of a project/library
  • automatically finds and adds needed sources and includes into the project's tree (non-recursive globbing); easy and flexible configuration process of source tree for current target: just add needed folder to list
  • automatically adds some of libraries (if possible): Boost, Qt5, Qt6
  • applies some compiler's extra flags because of safety. each compiler has a different set of flags: GCC, Clang or MSVC
  • automatically finds and adds Boost unit tests (don't use the dot symbol '.' in the name of test's source file!)
  • for MSVC automatically copies MS Visual C++ runtime libs to target building directory

How to

  1. clone that repositoy to your local machine
  2. add HERE specific sources and includes of your current project (example you can see HERE)
  3. add some external libraries HERE. example of attaching some external libraries:
...
#------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------
# ATTACH EXTERNAL LIBRARIES BELOW...

find_package(OpenCV REQUIRED)
target_link_libraries(${OUTPUT_NAME} PUBLIC opencv::opencv)

target_link_libraries(${OUTPUT_NAME} PUBLIC "${CMAKE_SOURCE_DIR}/myOwnSDK/lib/x64/libMySDK.so")
target_include_directories(${OUTPUT_NAME} SYSTEM PUBLIC "${CMAKE_SOURCE_DIR}/myOwnSDK/include")

find_package(Qt${QT_VERSION_MAJOR} COMPONENTS SerialPort Sql REQUIRED)
target_link_libraries(${OUTPUT_NAME} PUBLIC Qt::SerialPort)
target_link_libraries(${OUTPUT_NAME} PUBLIC Qt::Sql)
...
  1. add source of uint tests into folder test or add/change you testing configuration HERE. example of adding folder which contains set of unit tests for target:
...
#------------------------------------------------------------------------------------------------------
#------------------------------------------------------------------------------------------------------
# ADD TESTS BELOW...

target_add_tests_from_folder(${OUTPUT_NAME} "test")
...
  1. if needed, you can customize safety flags for your current compiler: GCC, Clang or MSVC

Extra variables

you can use some of variables in your own configuration:

  • variable SAFETY_FLAGS - contains the list of the compiler's flags (GCC, Clang and MSVC) to make your code more safe. example of usage you can find HERE, HERE and HERE
  • variable OUTPUT_NAME - the name of the current target name (target executable file name). usually it the same as varibale PROJECT_NAME, but for Qt6 application it different: app${PROJECT_NAME}. example of usage you can find HERE, HERE, HERE, HERE and HERE

Extra functions

you can use some of functions in your own configuration:

  • function get_sources_from_dir( SOURCES_DEST_VAR INCLUDES_DEST_VAR TARGET_FOLDER_PATH ) - scans TARGET_FOLDER_PATH and adds C++ files by the mask into variables: SOURCES_DEST_VAR (list of source files) and INCLUDES_DEST_VAR (list of include paths). examples of usage you can find HERE and HERE
  • function target_add_boost( TARGET_NAME ) - adds boost library to your target (if it possible). example of usage you can find HERE
  • function target_add_Qt( TARGET_NAME ) - adds Qt to your target (if it possible). example of usage you can find HERE
  • function target_add_tests_from_folder( TARGET_NAME FOLDER_PATH ) - applies Boost unit tests from specified folder (relative or absolute path) for specified target. each source file will be used as individual testing module. examples of usage you can find HERE (for TESTS), HERE (for TESTS) and HERE (for TESTS)

Tested on

  • Linux (GCC,Clang)
  • Windows (Clang,MinGW,MSVC)

Links

Why?

Why that template? Why globbing? Because most of IDEs don't support managing of project's files. So, in most of cases (in case of mine) it is pain and wasting of my working time to build and support (after refactoring, etc.) project's tree manually and define each source/include file in the project's file and maintain it at all the developing time. I prefer to keep project's filesystem cleany. And I prefer to use (except very rare cases) one known and standard structure of project's builing script (with easy way for customization) / known and standard tree of file system in each project, etc. I just prefer to use some standard template and know how it works, and don't think about that common things at all every time in each individual project (as it possible).

ucmakeskeleton's People

Contributors

r3d9477 avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.