Short OWBuild Introduction
Full OWBuild documentation is available here
OWBuild is a build system based on CMake. OWBuild is not a fork of CMake, it is simply a set of macros for CMake that simplifies C/C++ CMake scripts writing. If you are familiar with CMake syntax it will take you 5 minutes to be familiar with OWBuild.
Main advantage of using OWBuild over writing build scripts in CMake syntax is the simplicity and functionalities offered. Main functionality is the Oriented Object concept introduced by the functions ow_use_public_libraries() and ow_use_private_libraries(), this allows to easily write inter projects (libraries, executables) dependencies and increase modularity.
Examples
- A simple OWBuild script of a shared library named owcutil:
ow_create_shared_library(owcutil)
ow_add_public_include_dirs(
${CMAKE_CURRENT_SOURCE_DIR}/include
)
ow_add_sources(
src/fake.c
src/strlcat.c
src/strlcpy.c
)
if (MSVC)
ow_add_public_include_dirs(
${CMAKE_CURRENT_SOURCE_DIR}/include/cutil/msvc
)
ow_add_sources(
src/msvc/dirent.c
)
endif (MSVC)
ow_create_binary()
- An example of a shared library named owutil:
ow_create_shared_library(owutil)
ow_use_public_libraries(
owcutil
BOOST
)
ow_add_public_include_dirs(
${CMAKE_CURRENT_SOURCE_DIR}/include
)
ow_add_sources(
src/exception/Exception.cpp
src/Base64.cpp
src/CountryList.cpp
src/Date.cpp
src/File.cpp
src/Logger.cpp
src/OWPicture.cpp
src/Path.cpp
src/String.cpp
src/StringList.cpp
src/Time.cpp
src/Uuid.cpp
src/WebBrowser.cpp
)
if (WIN32)
ow_add_sources(
src/win/UuidWin.cpp
)
ow_add_private_libraries(
Rpcrt4
)
endif (WIN32)
if (APPLE)
ow_add_sources(
src/mac/UuidMac.cpp
)
ow_use_private_frameworks(
CoreFoundation
)
endif (APPLE)
if (LINUX)
ow_use_public_libraries(
UUID
)
ow_add_sources(
src/unix/UuidUnix.cpp
)
endif (LINUX)
ow_create_binary()
Library owutil depends on libraries BOOST and owcutil ow_use_public_libraries() handles defines, compiler flags, link flags, include directories...
Step by step OWBuild integration in your project
- Get OWBuild from: svn co https://dev.openwengo.com/svn/openwengo/owbuild/trunk/owbuild
- Copy OWBuild into a owbuild directory at the root of your project architecture
- Write a CMakeLists-owbuild.txt file at the root directory of your project:
project(owbuild) if (NOT OWBUILD_INCLUDED) # Where to look first for CMake modules, before ${CMAKE_ROOT}/Modules/ is checked set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/owbuild ${CMAKE_SOURCE_DIR}/owbuild/owbuild ) # Add OWBuild macros include(owbuild/owbuild/CMakeLists.txt) # Disallow in-source build ow_ensure_out_of_source_build() # Show general informations to the user include(owbuild/owbuild/OWInitializationInfo.cmake) endif (NOT OWBUILD_INCLUDED)
- Write a 'standard' CMakeLists.txt (root directory) that includes CMakeLists-owbuild.txt:
include(CMakeLists-owbuild.txt) [...]
- Now just use OWBuild syntax inside your CMakeLists.txt to compile a project, for example:
ow_create_executable(mytest) ow_add_sources( mytest.c ) ow_create_binary()
- Create and go to a build directory simply named 'build'
- Enter command cmake .. this will create all the Makefiles for your project to compile
- Enter command make under UNIX or nmake under Windows
- This will generate a binary mytest inside 'build/debug' directory
Here is your project organization with OWBuild integration (this is a suggestion):
/ -> project root directory
/owbuild -> OWBuild source code
/CMakeLists-owbuild.txt
/CMakeLists.txt
/build -> build directory where to run command {{{cmake ..}}}
/build/debug -> where compiled files are copied in debug mode
Attachments
- OWBuildPresentation-20070118.odp (15.3 kB) - added by cervajs 2 years ago.
