Commit 2327cd07 authored by Nicolas Van der Noot's avatar Nicolas Van der Noot
Browse files

cmakelists.txt for symbolic in MBsysC

parent 6f16d01e
#
# Author: Nicolas Van der Noot
# September 2015
#
# Static library for the symbolic files
#
cmake_minimum_required(VERSION 2.8.7)
project(MBproj_symbolicR)
# project configuration
set( CMAKE_C_FLAGS_RELEASE "-O3" )
set( CMAKE_CXX_FLAGS_RELEASE "-O3" )
# Variable for storing the path to Robotran common files (should be adapted depending on the location of those source)
set( ROBOTRAN_DIR_COMMON ${PROJECT_SOURCE_DIR}/../../../MBsysC/ )
set( ROBOTRAN_DIR_COPY ${PROJECT_SOURCE_DIR}/../mbsysCopy/ )
# change the following line with 'set( ROBOTRAN_SOURCE_DIR ${ROBOTRAN_DIR_COPY} )'' to use the Standalone version
set( ROBOTRAN_SOURCE_DIR ${ROBOTRAN_DIR_COMMON} )
# listing and flags CMake functions
add_subdirectory (${ROBOTRAN_SOURCE_DIR}/cmake_aux/listing/ ${PROJECT_BINARY_DIR}/cmake_aux/listing/)
add_subdirectory (${ROBOTRAN_SOURCE_DIR}/cmake_aux/flags/ ${PROJECT_BINARY_DIR}/cmake_aux/flags/)
# release of debug
release_debug()
# list source files to compile
init_src()
increment_src(./)
# list include directories (to find headers)
init_include()
increment_include(${ROBOTRAN_SOURCE_DIR})
add_library(MBproj_symbolicR STATIC ${SOURCE_FILES} ${INCLUDE_DIR})
## include directories
include_directories (${INCLUDE_DIR})
......@@ -14,15 +14,15 @@
function(list_files arg0 arg1 arg2)
file(GLOB_RECURSE SOURCE_FILES_TMP
"${arg2}/${arg1}")
set(CUR_DIR_LIST "")
set(CUR_SRC_LIST "")
foreach(FILE_PATH ${SOURCE_FILES_TMP})
string(REPLACE ${arg2} "" END_FILE ${FILE_PATH})
string(FIND ${END_FILE} "build" BUILD_PLACE)
if (${BUILD_PLACE} LESS 0)
set(CUR_DIR_LIST ${CUR_DIR_LIST} ${FILE_PATH})
set(CUR_SRC_LIST ${CUR_SRC_LIST} ${FILE_PATH})
endif ()
endforeach(FILE_PATH)
set(${arg0} ${CUR_DIR_LIST} PARENT_SCOPE)
set(${arg0} ${CUR_SRC_LIST} PARENT_SCOPE)
endfunction()
# list all source files (.c, .cc, .cpp)
......@@ -56,6 +56,37 @@ function(increment_src_file arg0)
endfunction()
## -- SRC FILES DIRECTORIES -- ##
# function to list all the directories containing source files
# with arg1 extensions, recursing into the folder arg2
# -> arg0 contains the list at the end
function(list_sub_dir arg0 arg1 arg2)
file(GLOB_RECURSE SOURCE_TMP "${arg2}/${arg1}")
set(CUR_DIR_LIST "")
foreach(FILE_PATH ${SOURCE_TMP})
get_filename_component(CUR_PATH ${FILE_PATH} PATH)
if (NOT "${CUR_DIR_LIST}" MATCHES "${CUR_PATH}")
set(CUR_DIR_LIST ${CUR_DIR_LIST} ${CUR_PATH})
endif()
endforeach(FILE_PATH)
set(${arg0} ${CUR_DIR_LIST} PARENT_SCOPE)
endfunction()
# function to list all the directories containing C or C++ source files,
# recursing into the folder arg1
# -> arg0 contains the list at the end
function(list_src_sub_dir arg0 arg1)
set(CUR_FULL_LIST "")
list_sub_dir(CUR_LIST "*.c" ${arg1})
set(CUR_FULL_LIST ${CUR_LIST})
list_sub_dir(CUR_LIST "*.cc" ${arg1})
set(CUR_FULL_LIST ${CUR_FULL_LIST} ${CUR_LIST})
list_sub_dir(CUR_LIST "*.cpp" ${arg1})
set(CUR_FULL_LIST ${CUR_FULL_LIST} ${CUR_LIST})
set(${arg0} ${CUR_FULL_LIST} PARENT_SCOPE)
endfunction()
## -- INCLUDE DIRECTORIES -- ##
......
......@@ -15,7 +15,7 @@ function(make_options)
# scripts executable
execute_process(COMMAND chmod +x ${SCRIPTS_PATH}/mbsysc_build)
execute_process(COMMAND chmod +x ${SCRIPTS_PATH}/stat_symbolic)
execute_process(COMMAND chmod +x ${SCRIPTS_PATH}/symbolic_lib)
# mbsysc_options (options listing with an example of cmake script)
add_custom_target(mbsysc_options COMMAND ${CMAKE_COMMAND} -P ${SCRIPTS_PATH}/mbsysc_options )
......@@ -36,10 +36,10 @@ function(make_options)
add_custom_target(mbsysc_clean COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./mbsysc_build ${ROBOTRAN_SOURCE_DIR} "clean")
# symb_lib
add_custom_target(symb_lib COMMAND ${CMAKE_COMMAND} -P ${SCRIPTS_PATH}/iterative_symb ${PROJECT_SOURCE_DIR} ${ROBOTRAN_SOURCE_DIR})
add_custom_target(symb_lib COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./symbolic_lib ${PROJECT_SOURCE_DIR}/../symbolicR ${ROBOTRAN_SOURCE_DIR}/mbs_app/symbolic_lib)
# symb_clean
add_custom_target(symb_clean COMMAND ${CMAKE_COMMAND} -P ${SCRIPTS_PATH}/iterative_symb ${PROJECT_SOURCE_DIR} ${ROBOTRAN_SOURCE_DIR} "clean")
add_custom_target(symb_clean COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./symbolic_lib ${PROJECT_SOURCE_DIR}/../symbolicR ${ROBOTRAN_SOURCE_DIR}/mbs_app/symbolic_lib "clean")
endif ( )
......
#
# Author: Nicolas Van der Noot
# September 2015
#
# Iterative CMake scripts call
#
# get arguments
set (PROJECT_DIR ${CMAKE_ARGV3})
set (ROBOTRAN_DIR ${CMAKE_ARGV4})
# requested script
set (SCRIPT_SYMB "${ROBOTRAN_DIR}/cmake_aux/scripts/symbolic_lib")
# recursive iteration
file(GLOB_RECURSE CMAKE_SYMB_FILES "${PROJECT_DIR}/../symbolicR/*CMakeLists.txt")
foreach(CMAKE_FILE ${CMAKE_SYMB_FILES})
get_filename_component(CUR_PATH ${CMAKE_FILE} PATH)
execute_process(COMMAND ${SCRIPT_SYMB} ${CUR_PATH} ${CMAKE_ARGV5})
endforeach(CMAKE_FILE)
......@@ -43,4 +43,4 @@ echo " FLAG_VISU : $7\n"
make
echo "\n Dynamic libraries created in: "
echo " $1build \n"
echo " $1/build \n"
......@@ -5,33 +5,31 @@
# Static symbolic library build: configuration and compilation
#
if [ $# = 1 ]
# create empty directory
if [ -d $2/build/ ]
then
echo "\n Static symbolic library creation \n"
else
if [ -d $1/build/ ]
then
echo "\n Static symbolic library cleaning \n"
rm -r $1/build/
fi
exit
rm -r $2/build/
fi
mkdir $2/build/
# create empty directory
if [ -d $1/build/ ]
cd $2/build
if [ $# = 2 ]
then
rm -r $1/build/
fi
mkdir $1/build/
echo "\n Static symbolic library creation \n"
# generate CMake project
cd $1/build/
cmake $1 -DFLAG_RELEASE=ON
# CMake project configuration
cmake $2 -DSYMB_PATH=$1 -DCLEAN_OPT=OFF
echo ""
# compilation
make -j4
else
echo "\n Static symbolic library cleaning \n"
# CMake project configuration
cmake $2 -DSYMB_PATH=$1 -DCLEAN_OPT=ON
fi
# compilation
make -j4
# remove directory
rm -r $2/build
echo "\n Static symbolic library created in: "
echo " $1/build \n"
#
# Author: Nicolas Van der Noot
# September 2015
#
# Static library for all the symbolic files
#
cmake_minimum_required(VERSION 2.8.7)
project(MBproj_symbolicR)
# project configuration
set( CMAKE_C_FLAGS_RELEASE "-O3" )
set( CMAKE_CXX_FLAGS_RELEASE "-O3" )
set( ROBOTRAN_SOURCE_DIR ${PROJECT_SOURCE_DIR}/../.. )
# symbolic path
set (SYMB_PATH "${PROJECT_SOURCE_DIR}" CACHE STRING "Some user-specified option")
set (CLEAN_OPT "OFF" CACHE STRING "Some user-specified option")
# scripts path
set( SCRIPTS_PATH ${ROBOTRAN_SOURCE_DIR}/cmake_aux/scripts )
# listing and flags CMake functions
add_subdirectory (${ROBOTRAN_SOURCE_DIR}/cmake_aux/listing/ ${PROJECT_BINARY_DIR}/cmake_aux/listing/)
add_subdirectory (${ROBOTRAN_SOURCE_DIR}/cmake_aux/flags/ ${PROJECT_BINARY_DIR}/cmake_aux/flags/)
# release of debug
release_debug()
# list all folders
list_src_sub_dir(SYMB_DIRECTORIES ${SYMB_PATH})
# counter
set(I_COUNT 1)
# iterate on each folder
foreach(CUR_DIR ${SYMB_DIRECTORIES})
# clean old directory
file( REMOVE_RECURSE ${CUR_DIR}/build )
if (NOT CLEAN_OPT)
# create build directory
file( MAKE_DIRECTORY ${CUR_DIR}/build )
# list source files to compile
init_src()
increment_src( ${CUR_DIR} )
# list include directories (to find headers)
init_include()
increment_include( ${CUR_DIR} )
increment_include( ${ROBOTRAN_SOURCE_DIR} )
## include directories
include_directories (${INCLUDE_DIR})
# current library name
set (CUR_LIB_NAME MBproj_symbolicR_${I_COUNT})
# increment counter
MATH(EXPR I_COUNT "${I_COUNT}+1")
# create library
add_library( ${CUR_LIB_NAME} STATIC ${SOURCE_FILES} ${INCLUDE_DIR} )
# send library to symbolic folder
add_custom_command ( TARGET ${CUR_LIB_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E copy ${PROJECT_BINARY_DIR}/lib${CUR_LIB_NAME}.a ${CUR_DIR}/build )
add_custom_command ( TARGET ${CUR_LIB_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E rename ${CUR_DIR}/build/lib${CUR_LIB_NAME}.a ${CUR_DIR}/build/libMBproj_symbolicR.a )
add_custom_command ( TARGET ${CUR_LIB_NAME} POST_BUILD COMMAND ${CMAKE_COMMAND} ARGS -E remove ${PROJECT_BINARY_DIR}/lib${CUR_LIB_NAME}.a )
endif()
endforeach(CUR_DIR)
......@@ -19,11 +19,11 @@ set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} PARENT_SCOPE)
# list source files to compile
init_src()
increment_src(./)
increment_src( ${PROJECT_SOURCE_DIR} )
# list include directories (to find headers)
init_include()
set(INCLUDE_DIR ${INCLUDE_DIR} "./" PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR} PARENT_SCOPE)
if(FLAG_SHARED_LIB)
add_library(MBsysC_loadXML SHARED ${SOURCE_FILES} ${INCLUDE_DIR})
......
......@@ -23,11 +23,11 @@ set(GSL_LIBRARIES ${GSL_LIBRARIES} PARENT_SCOPE)
# list source files to compile
init_src()
increment_src(./)
increment_src( ${PROJECT_SOURCE_DIR} )
# list include directories (to find headers)
init_include()
set(INCLUDE_DIR ${INCLUDE_DIR} "./" PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR} PARENT_SCOPE)
# remove some compilation warnings (This line should be removed once the loading, equil and modal modules are stabilized)
if (UNIX)
......
......@@ -15,11 +15,11 @@ release_debug()
# list source files to compile
init_src()
increment_src(./)
increment_src( ${PROJECT_SOURCE_DIR} )
# list include directories (to find headers)
init_include()
set(INCLUDE_DIR ${INCLUDE_DIR} "./" PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR} PARENT_SCOPE)
add_library(MBsysC_numerics ${SOURCE_FILES} ${INCLUDE_DIR})
......
......@@ -15,8 +15,8 @@ release_debug()
# list source files to compile
init_src()
increment_src(./realtime)
increment_src(./void)
increment_src( ${PROJECT_SOURCE_DIR}/realtime )
increment_src( ${PROJECT_SOURCE_DIR}/void )
# Get SDL lib and add plot functions to src
if (FLAG_PLOT)
......@@ -26,7 +26,7 @@ if (FLAG_PLOT)
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} PARENT_SCOPE)
set(SDL2TTF_LIBRARIES ${SDL2TTF_LIBRARIES} PARENT_SCOPE)
increment_src(./sdl)
increment_src( ${PROJECT_SOURCE_DIR}/sdl )
# configure a header file to pass some of the CMake settings to the source code
set(SDL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/sdl/SDL_files)
......@@ -47,7 +47,7 @@ if (FLAG_VISU)
set (J3D_PATH ${J3D_PATH} PARENT_SCOPE)
include_directories("./java")
increment_src(./java)
increment_src( ${PROJECT_SOURCE_DIR}/java )
set(JAR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../mbsyspad/MBsysPad.jar)
......@@ -60,7 +60,7 @@ endif ()
# list include directories (to find headers)
init_include()
set(INCLUDE_DIR ${INCLUDE_DIR} "./realtime" PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/realtime PARENT_SCOPE)
add_library(MBsysC_realtime ${SOURCE_FILES} ${INCLUDE_DIR})
......
......@@ -15,11 +15,11 @@ release_debug()
# list source files to compile
init_src()
increment_src(./)
increment_src( ${PROJECT_SOURCE_DIR} )
# list include directories (to find headers)
init_include()
set(INCLUDE_DIR ${INCLUDE_DIR} "./" PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR} PARENT_SCOPE)
add_library(MBsysC_struct ${SOURCE_FILES} ${INCLUDE_DIR})
......
......@@ -15,12 +15,12 @@ release_debug()
# list source files to compile
init_src()
increment_src(./)
increment_src( ${PROJECT_SOURCE_DIR} )
# list include directories (to find headers)
init_include()
set(INCLUDE_DIR ${INCLUDE_DIR} "./" PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} "./auto_output" PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR} PARENT_SCOPE)
set(INCLUDE_DIR ${INCLUDE_DIR} ${PROJECT_SOURCE_DIR}/auto_output PARENT_SCOPE)
if(FLAG_SHARED_LIB)
add_library(MBsysC_utilities SHARED ${SOURCE_FILES} ${INCLUDE_DIR})
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment