forefireAPI / firefront

ForeFire is an open-source code for wildland fire spread models
GNU General Public License v2.0
37 stars 20 forks source link

Try Cmake compiler to reduce compilation time #9

Closed antonio-leblanc closed 1 year ago

antonio-leblanc commented 2 years ago

Alternative Build Tools for C++ projects

https://www.g2.com/products/scons/competitors/alternatives

https://julienjorge.medium.com/an-overview-of-build-systems-mostly-for-c-projects-ac9931494444

antonio-leblanc commented 2 years ago

Scons vs Cmake

https://www.reddit.com/r/embedded/comments/q8foqe/scons_vs_cmake/

"Having used both, I vastly prefer CMake. Currently using the Ninja generator for most of my projects, it's much faster than SCons.

One aspect worth considering is accessibility and ease of maintenance. SCons is a framework for constructing your own special one-off build system. It can be extremely difficult for others to use and modify as a result--knowledge gained from other SCons-based projects may well not carry over. CMake, when used properly, is extremely standardised. Anyone familiar with CMake will be able to use and modify your build. This lowers the cost and time for working on the build system within your project.

CMake continues to evolve and add useful features. Cross-compiling with toolchain files makes it easy to build with different compilers. And the new presets features makes it easy to define the supported set of build configurations you want to work on for development and releasing, again standardising things across your teams and making it easy for people to get up and running with it."

antonio-leblanc commented 2 years ago

1st commit trying cmake build https://github.com/forefireAPI/firefront/commit/9c72e758aff3423eff52b396beea24ede32af6a5

Not working yet, Still need to figure how to link netcdf library

Ressources

Cmake

Questions

Netcdf C++ Utils

Other

antonio-leblanc commented 1 year ago

CMakeLists.txt

cmake_minimum_required(VERSION 3.10)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)

project(forefire VERSION 1.0)

file(GLOB_RECURSE SRC_FILES src/*.cpp)

add_executable(forefire ${SRC_FILES})

target_include_directories(forefire PUBLIC usr/include)

# NOT WORKING YET -> SHOULD include netcdf
antonio-leblanc commented 1 year ago

cmake-build.sh

mkdir cmakebuild
cd cmakebuild
cmake ../
make
antonio-leblanc commented 1 year ago

MAKE

Using makefile only

Understanding Link Libraries Flags in Make and Cmake

Improve build structure

antonio-leblanc commented 1 year ago

Bonus