[cmake-developers] [CMake 0011807]: SAP - Super Awesome Projects - boost-cmake like macros with added project inheritance feature.
Mantis Bug Tracker
mantis at public.kitware.com
Sat Feb 5 16:12:18 EST 2011
The following issue has been SUBMITTED.
======================================================================
http://www.cmake.org/Bug/view.php?id=11807
======================================================================
Reported By: Brian J. Davis
Assigned To:
======================================================================
Project: CMake
Issue ID: 11807
Category: CMake
Reproducibility: N/A
Severity: feature
Priority: low
Status: new
======================================================================
Date Submitted: 2011-02-05 16:12 EST
Last Modified: 2011-02-05 16:12 EST
======================================================================
Summary: SAP - Super Awesome Projects - boost-cmake like
macros with added project inheritance feature.
Description:
SAP - Super Awesome Projects - boost-cmake like macros with added project
inheritance feature. Some of this may be being tackled with in the project
ryppl which I have not tried. I recently created this for a class I am taking
and put it in compact form which I am now uploading to ask for as a feature
request. I did this to limit the verbosity of CMake when adding new libs and
exe's. I also wanted a mechanism closer to bjam syntax. Maybe there is a
better way of doing this with vanilla CMake if so I don't see it.
After using CMake for a while and browsing through the boost-cmake repo I came
up with a mechanism to create projects. One of my other goals was to include
other CMake Projects such as VTK, ITK, boost-cmake, dcmtk, and others into an
uber project. This attempt met with drastically awful results. Maybe CMake can
be made to play nicely with itself in this regard. For more open the google and
search "build only what you need in third party libs". There are posts on the
forums regarding my trails and tribulations on this front.
These macros have an inheritance feature where one project can be specified.
This is currently a prototype example and there are likely better ways of doing
this. I also need to fix the inherited projects and library linking issue, but
this serves at least as a working example.
Not every feature of CMake is supported and I have been working to figure out
away to do this in a modular fasion. Supported features can be seen by looking
through the .cmake files and looking for:
set( ARGUMENT_NAMES
INHERIT_CONFIGURATIONS
SOURCE_DIRECTORIES
CPP_SOURCES
CU_SOURCES
DEFINES
LINK_LIBS
INCLUDE_DIRECTORIES
LINK_DIRECTORIES
CUDA_APP
INSTALL_DIRECTORIES
DEPENDENCIES
LINK_FLAGS
LINKER_LANGUAGE
${COMPILE_FLAG_TYPES}
)
The scripts are located in the ./CMake/Modules section of the provided zip.
./CMake/Modules
./CMake/Modules/Findsap.cmake
./CMake/Modules/sap
./CMake/Modules/sap/add_project.cmake
./CMake/Modules/sap/add_project_configuration.cmake
./CMake/Modules/sap/add_project_executable.cmake
./CMake/Modules/sap/add_project_library.cmake
./CMake/Modules/sap/debug_message.cmake
./CMake/Modules/sap/parse_project_arguments.cmake
./CMake/Modules/sap/patch.cmake
./CMake/Modules/sap/set_if_found.cmake
./CMake/Modules/sap/touch_file.cmake
./CMake/Modules/sap/unpack.cmake
The inheritance feature can be specified as an example by:
project( project_name )
add_project_configuration(
boost_headers_config
INCLUDE_DIRECTORIES
${BOOST_INCLUDE_DIR}
)
SET( BOOST_LIB_POSTFIX "-vc90-mt-1_41" )
SET( BOOST_LIB_PREFIX "lib" )
add_project_configuration(
boost_config
INCLUDE_DIRECTORIES
${BOOST_INCLUDE_DIR}
LINK_DIRECTORIES
${CMAKE_INSTALL_PREFIX}/lib
${BOOST_STAGE_DIR}/lib
LINK_LIBS
${BOOST_LIB_PREFIX}boost_system${BOOST_LIB_POSTFIX}
${BOOST_LIB_PREFIX}boost_date_time${BOOST_LIB_POSTFIX}
${BOOST_LIB_PREFIX}boost_filesystem${BOOST_LIB_POSTFIX}
${BOOST_LIB_PREFIX}boost_serialization${BOOST_LIB_POSTFIX}
)
add_project_configuration(
vtk_config
LINK_DIRECTORIES
${CMAKE_INSTALL_PREFIX}/lib
${CMAKE_INSTALL_PREFIX}/lib/vtk-${VTK_LIB_VERSION_INCLUDE}
${CMAKE_INSTALL_PREFIX}/lib/VTKEdge
LINK_LIBS
vtkCommon
vtkDICOMParser
vtkFiltering
vtkGraphics
vtkImaging
vtkIO
vtkRendering
vtkVolumeRendering
vtkKWEVolumeRendering
vtkKWECommon
)
add_project_library
myLib
INHERIT_CONFIGURATIONS
project_name_boost_config
project_name_vtk_config
INCLUDE_DIRECTORIES
${CMAKE_CURRENT_SOURCE_DIR}/../include
CPP_SOURCES
myLib.cpp
CU_SOURCES
myLib.cu
INSTALL_DIRECTORIES
lib
)
add_project_configuration(
mylib_config
LINK_LIBS
myLib
)
add_project_executable(
myApp
INHERIT_CONFIGURATIONS
project_name_mylib_config
INSTALL_DIRECTORIES
bin
)
See add_project_configuration, add_project_ececutable.cmake add_project_library,
and parse_project_arguments.cmake in attached zip.
parse_project_arguments may be found to be interesting as this is what generates
the xml files so that a developer can see what sap reads from the configuration.
I thought about calling this a Parse Arguments Hack (PAH) instead of SAP, but
sap was preferred and the letters are flexible enough to make other acronyms for
people that despise this approach like stupid analytical processing, [put yours
here],....
An example is below:
- <project>
- <ME964_cuda_config>
<DEFAULT_ARGS />
- <INCLUDE_DIRECTORIES>
<paramater>"C:/CUDA/include"</paramater>
<paramater>"C:/Documents and Settings/All Users/Application Data/NVIDIA
Corporation/NVIDIA GPU Computing SDK/C/common/inc"</paramater>
</INCLUDE_DIRECTORIES>
- <LINK_DIRECTORIES>
<paramater>"C:/Documents and Settings/All Users/Application Data/NVIDIA
Corporation/NVIDIA GPU Computing SDK/C/common/lib"</paramater>
</LINK_DIRECTORIES>
- <LINK_LIBS>
<paramater>"cublas"</paramater>
<paramater>"cuda"</paramater>
<paramater>"cudart"</paramater>
<paramater>"cufft"</paramater>
<paramater>"cutil_x86_64D"</paramater>
</LINK_LIBS>
</ME964_cuda_config>
</project>
Steps to Reproduce:
- unzip the archive
- read the README.txt at top of tree
- install missing CMake .tar.gz (Linux) or .zip (WinXP/Windows7 x64/Windows
Server 2008 x64 and ver B) boost if desired (not necessary) and GNUWin32
unzip.exe
- move in to place CMakeLists.txt.example to CMakeLists.txt
- run go.bat if the .zips, .tars, and unzip.exe are in place and wait for the
CMake magic (unpack) to happen
- use cmake to configure the example.
- browse through the various .xml generated files and project example in
source/cpp/project1
Needed bits if you want it to auto configure itself.
Windows
./platform/3rdParty/Win/boost/boost-cmake-1_41_0.zip
./platform/3rdParty/Win/cmake/cmake-2.8.2-win32-x86.zip
Linux
./platform/3rdParty/Linux/boost/boost_1_45_0.tar.gz
./platform/3rdParty/Linux/cmake/cmake-2.8.3.tar.gz
Linux and Windows
./platform/3rdParty/Win/GNUWin32/unzip.exe
======================================================================
Issue History
Date Modified Username Field Change
======================================================================
2011-02-05 16:12 Brian J. Davis New Issue
2011-02-05 16:12 Brian J. Davis File Added: release.zip
======================================================================
More information about the cmake-developers
mailing list