Building¶
SCONS¶
The library is usually built using CMake, but is also intended to be buildable as a part for SCons using the Parts <https://pypi.org/project/scons-parts/> extensions. For this reason the overall codebase is split into the library code and the test code. As a library only the library code needs to be built, which is the part “swoc++/swoc++.part”. For example, to get the 1.0.8 release as a library in a larger project, the top level “Sconstruct” would have
Part("swoc++/swoc++.part"
, vcs_type=VcsGit(server="github.com"
, repository="SolidWallOfCode/libswoc"
, tag="1.0.8"))
The object that depends on this library would then have
DependsOn([
# ... other dependencies
, Component("swoc++")
, # ... more dependencies
])
CMake¶
- The library can be built directly with CMake. To use libswoc in another CMake project use ::
- FetchContent_Declare(
libSWOC GIT_REPOSITORY “https://github.com/solidwallofcode/libswoc” GIT_TAG “master”
) set(LIBSWOC_INSTALL off) FetchContent_MakeAvailable(libSWOC)
This will fetch the latest version. GIT_TAG can be changed to any release tag to use a specific
release (usually the better choice). Disabling LIBSWOC_INSTALL prevents the install logic in
libswoc from interfering with the current project. For a target such as “plugin” that needs libswoc
to build
target_link_libraries(plugin PRIVATE libswoc)
target_include_directories(plugin PRIVATE libswoc)
To build from the command line
cmake .
cmake --build .
cmake --install . --prefix /install/dir