now cmake takes snippets of code, completes them into compilable sources, builds them,

executes them and stores their output in files.
This commit is contained in:
Benoit Jacob 2007-12-21 09:30:32 +00:00
parent ee3410f79a
commit a316cd8a76
4 changed files with 31 additions and 21 deletions

View File

@ -1,6 +1,10 @@
IF(BUILD_DOC)
CONFIGURE_FILE( CONFIGURE_FILE(
${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in
${CMAKE_CURRENT_BINARY_DIR}/Doxyfile ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile
) )
ADD_SUBDIRECTORY(examples) ADD_SUBDIRECTORY(snippets)
ENDIF(BUILD_DOC)

View File

@ -1,14 +1,20 @@
FILE(GLOB examples_SRCS "*.cpp") FILE(GLOB snippets_SRCS "*.cpp")
FOREACH(example_src ${examples_SRCS}) FOREACH(snippet_src ${snippets_SRCS})
GET_FILENAME_COMPONENT(example ${example_src} NAME_WE) GET_FILENAME_COMPONENT(snippet ${snippet_src} NAME_WE)
ADD_EXECUTABLE(${example} ${example_src}) SET(compile_snippet_target compile_${snippet})
GET_TARGET_PROPERTY(example_executable ${example} LOCATION) SET(compile_snippet_src ${compile_snippet_target}.cpp)
FILE(READ ${snippet_src} snippet_source_code)
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/compile_snippet.cpp.in
${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
ADD_EXECUTABLE(${compile_snippet_target}
${CMAKE_CURRENT_BINARY_DIR}/${compile_snippet_src})
GET_TARGET_PROPERTY(compile_snippet_executable
${compile_snippet_target} LOCATION)
ADD_CUSTOM_COMMAND( ADD_CUSTOM_COMMAND(
TARGET ${example} TARGET ${compile_snippet_target}
POST_BUILD POST_BUILD
COMMAND ${example_executable} COMMAND ${compile_snippet_executable}
ARGS >${CMAKE_CURRENT_BINARY_DIR}/${example}.out ARGS >${CMAKE_CURRENT_BINARY_DIR}/${snippet}.out
) )
MESSAGE(coucou) ENDFOREACH(snippet_src)
ENDFOREACH(example_src)

View File

@ -0,0 +1,7 @@
#include <Eigen/Core.h>
USING_EIGEN_DATA_TYPES
using namespace std;
int main(int, char**)
{
${snippet_source_code}
}

View File

@ -1,10 +1,3 @@
#include <Eigen/Core.h> Matrix4d m = Matrix4d::identity();
USING_EIGEN_DATA_TYPES m.dynBlock(2,0,2,2) = m.dynBlock(0,0,2,2);
using namespace std; cout << m << endl;
int main(int, char**)
{
Matrix4d m = Matrix4d::identity();
m.dynBlock(2,0,2,2) = m.dynBlock(0,0,2,2);
cout << m << endl;
return 0;
}