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

symbolic static compilation

parent 3bd09a21
#
# Author: Nicolas Van der Noot
# September 2015
#
# Static library for the symbolic files
#
cmake_minimum_required(VERSION 2.8.7)
project(MBproj_symbolicR)
# 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 CMake functions
add_subdirectory (${ROBOTRAN_SOURCE_DIR}/cmake_aux/listing/ ${PROJECT_BINARY_DIR}/cmake_aux/listing/)
# 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})
......@@ -92,7 +92,10 @@ init_src()
increment_src( ${PROJECT_SOURCE_DIR}/src )
increment_src( ${PROJECT_SOURCE_DIR}/../userfctR )
increment_src( ${PROJECT_SOURCE_DIR}/../symbolicR )
if (NOT FLAG_SEPARATE_SYMBOLIC)
increment_src( ${PROJECT_SOURCE_DIR}/../symbolicR )
endif ( )
increment_void_symbolic(symbolicR)
......@@ -128,6 +131,8 @@ endif ( )
set(CMAKE_MODULE_PATH ${ROBOTRAN_SOURCE_DIR}/conf)
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# EXECUTABLE COMPILATION
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
......@@ -146,6 +151,8 @@ add_executable ( ${Executable} ${SOURCE_FILES} )
# EXECUTABLE LINKING
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
if (FLAG_SEPARATE_BUILD) # find MBSysC dynamic libraries
find_package( LibRobotranC REQUIRED )
......@@ -177,7 +184,17 @@ else ( )
endif ( )
# separate symbolic files compilation
if ( FLAG_SEPARATE_SYMBOLIC )
find_package( LibSymbolicR REQUIRED )
target_link_libraries( ${Executable} ${LIB_PROJ_SYMB} )
endif ( )
# math external library (for Unix)
if (UNIX)
target_link_libraries ( ${Executable} m )
endif ( )
......@@ -69,8 +69,6 @@ int main(int argc, char const *argv[])
mbs_dirdyn->options->save2file = 1;
mbs_dirdyn->options->respath = PROJECT_SOURCE_DIR"/../resultsR";
mbs_dirdyn->options->realtime = 1;
mbs_run_dirdyn(mbs_dirdyn, mbs_data);
mbs_delete_dirdyn(mbs_dirdyn, mbs_data);
......
......@@ -9,10 +9,15 @@
# FLAGS
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
## -- Release or debug -- ##
# use Release version (otherwise: Debug)
option (FLAG_RELEASE
"Release" ON)
## -- Real-time features related -- ##
# run the simulation in real-time
option (FLAG_REAL_TIME
"Real time" OFF)
......@@ -25,6 +30,9 @@ option (FLAG_PLOT
option (FLAG_VISU
"Java visualization" ON)
## -- Static, dynamic libraries -- ##
# Compile Robotran MBSysC as shared lib (.so / .dll)
option (FLAG_SHARED_LIB
"Compile as dynamic lib" OFF)
......@@ -33,6 +41,10 @@ option (FLAG_SHARED_LIB
option (FLAG_SEPARATE_BUILD
"Link to MBSysC lib already compiled" OFF)
# Link to symbolic files already compiled
option (FLAG_SEPARATE_SYMBOLIC
"Link to symbolic files already compiled" OFF)
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
......
......@@ -8,12 +8,21 @@
## -- SRC FILES -- ##
# function to list all files whose form equals arg1,
# recursing into the folder arg2
# recursing into the folder arg2 (excluding source files inside a 'build folder'
# to prevent CMake incompatibilities)
# -> arg0 contains the list at the end
function(list_files arg0 arg1 arg2)
file(GLOB_RECURSE SOURCE_FILES_TMP
"${arg2}/${arg1}")
set(${arg0} ${SOURCE_FILES_TMP} PARENT_SCOPE)
set(CUR_DIR_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})
endif ()
endforeach(FILE_PATH)
set(${arg0} ${CUR_DIR_LIST} PARENT_SCOPE)
endfunction()
# list all source files (.c, .cc, .cpp)
......@@ -47,6 +56,44 @@ function(increment_src_file arg0)
endfunction()
## -- INCLUDE DIRECTORIES -- ##
# function to list all directories containing ".h", ".hh" and ".hpp" files,
# recursing into the folder arg1
# -> arg0 contains the list at the end
function(list_include_directories arg0 arg1)
file(GLOB_RECURSE SOURCE_FILES_TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"${arg1}/*.h"
"${arg1}/*.hh"
"${arg1}/*.hpp")
set(CUR_DIR_LIST "")
foreach(FILE_PATH ${SOURCE_FILES_TMP})
get_filename_component(CUR_PATH ${FILE_PATH} PATH)
set(CUR_DIR_LIST ${CUR_DIR_LIST} ${CUR_PATH})
endforeach(FILE_PATH)
list(REMOVE_DUPLICATES CUR_DIR_LIST)
set(${arg0} ${CUR_DIR_LIST} PARENT_SCOPE)
endfunction()
# reset INCLUDE_DIR
function(init_include)
set(INCLUDE_DIR "" PARENT_SCOPE)
endfunction()
# increment INCLUDE_DIR with the files in the arg0 folder (recursively)
function(increment_include arg0)
list_include_directories(CUR_INCLUDE_DIR ${arg0})
set(INCLUDE_DIR ${INCLUDE_DIR} ${CUR_INCLUDE_DIR} PARENT_SCOPE)
endfunction()
# increment INCLUDE_DIR with the arg0 file (specific header file)
function(increment_include_file arg0)
set(INCLUDE_DIR ${INCLUDE_DIR} ${arg0} PARENT_SCOPE)
endfunction()
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# CHECKING SYMBOLIC FILES
#
......@@ -125,39 +172,3 @@ function(increment_void_symbolic arg0)
set(SOURCE_FILES ${SOURCE_FILES} ${VOID_SYMBOLIC} PARENT_SCOPE)
endfunction()
## -- INCLUDE DIRECTORIES -- ##
# function to list all directories containing ".h", ".hh" and ".hpp" files,
# recursing into the folder arg1
# -> arg0 contains the list at the end
function(list_include_directories arg0 arg1)
file(GLOB_RECURSE SOURCE_FILES_TMP RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
"${arg1}/*.h"
"${arg1}/*.hh"
"${arg1}/*.hpp")
set(CUR_DIR_LIST "")
foreach(FILE_PATH ${SOURCE_FILES_TMP})
get_filename_component(CUR_PATH ${FILE_PATH} PATH)
set(CUR_DIR_LIST ${CUR_DIR_LIST} ${CUR_PATH})
endforeach(FILE_PATH)
list(REMOVE_DUPLICATES CUR_DIR_LIST)
set(${arg0} ${CUR_DIR_LIST} PARENT_SCOPE)
endfunction()
# reset INCLUDE_DIR
function(init_include)
set(INCLUDE_DIR "" PARENT_SCOPE)
endfunction()
# increment INCLUDE_DIR with the files in the arg0 folder (recursively)
function(increment_include arg0)
list_include_directories(CUR_INCLUDE_DIR ${arg0})
set(INCLUDE_DIR ${INCLUDE_DIR} ${CUR_INCLUDE_DIR} PARENT_SCOPE)
endfunction()
# increment INCLUDE_DIR with the arg0 file (specific header file)
function(increment_include_file arg0)
set(INCLUDE_DIR ${INCLUDE_DIR} ${arg0} PARENT_SCOPE)
endfunction()
......@@ -14,6 +14,7 @@ function(make_options)
# scripts executable
execute_process(COMMAND chmod +x ${SCRIPTS_PATH}/dyn_build)
execute_process(COMMAND chmod +x ${SCRIPTS_PATH}/stat_symbolic)
# dyn_options (options listing with an example of cmake script)
add_custom_target(dyn_options COMMAND ${CMAKE_COMMAND} -P ${SCRIPTS_PATH}/dyn_options )
......@@ -31,9 +32,14 @@ function(make_options)
add_custom_target(dyn_realtime COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./dyn_build ${ROBOTRAN_SOURCE_DIR} ON ON ON ON ON ON)
# dyn_clean (SHARED_LIB, SEPARATE_BUILD, RELEASE, REAL_TIME, PLOT, VISU)
add_custom_target(dyn_clean COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./dyn_build ${ROBOTRAN_SOURCE_DIR})
add_custom_target(dyn_clean COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./dyn_build ${ROBOTRAN_SOURCE_DIR} "clean")
# symb_stat
add_custom_target(symb_stat COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./stat_symbolic ${PROJECT_SOURCE_DIR}/../symbolicR)
# symb_clean
add_custom_target(symb_clean COMMAND ${CMAKE_COMMAND} -E chdir ${SCRIPTS_PATH} ./stat_symbolic ${PROJECT_SOURCE_DIR}/../symbolicR "clean")
endif ( )
endfunction()
......@@ -9,8 +9,11 @@ if [ $# = 7 ]
then
echo "\n Dynamic libraries creation \n"
else
echo "\n Dynamic libraries cleaning \n"
rm -r $1/build/
if [ -d $1/build/ ]
then
echo "\n Dynamic libraries cleaning \n"
rm -r $1/build/
fi
exit
fi
......@@ -22,7 +25,6 @@ mkdir $1/build/
cd $1/build/
cmake $1/mbs_common -DFLAG_SHARED_LIB=$2 -DFLAG_SEPARATE_BUILD=$3 -DFLAG_RELEASE=$4 -DFLAG_REAL_TIME=$5 -DFLAG_PLOT=$6 -DFLAG_VISU=$7
# messages
echo "\n Dynamic libraries configured in: "
echo " $1build"
......@@ -34,6 +36,7 @@ echo " FLAG_REAL_TIME : $5"
echo " FLAG_PLOT : $6"
echo " FLAG_VISU : $7\n"
# compilation
make
echo "\n Dynamic libraries created in: "
......
#
# Author: Nicolas Van der Noot
# September 2015
#
# Static symbolic library build: configuration and compilation
#
if [ $# = 1 ]
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
fi
# create empty directory
rm -r $1/build/
mkdir $1/build/
# generate CMake project
cd $1/build/
cmake $1
echo ""
# compilation
make -j4
echo "\n Static symbolic library created in: "
echo " $1/build \n"
......@@ -10,7 +10,6 @@
# SDL2_LIBRARIES : libraries -> for linkage
#
IF (UNIX)
IF (APPLE)
......@@ -60,11 +59,8 @@ ELSE (UNIX)
## ---- WINDOWS ---- ##
ENDIF (UNIX)
# flag put to 1 if all required files are found
IF(LIB_MBSYSC_MODULES AND LIB_MBSYSC_LOAD AND LIB_MBSYSC_UTILITIES)
SET(ROBOTRAN_C_FOUND 1)
......
#
# author: Nicolas Van der Noot
# September 2015
#
# This file finds the static libraries
# related to the project symbolic files
#
# PROJ_SYMB_FOUND : 1 if all required files found (0 otherwise)
# LIB_PROJ_SYMB : static library -> for linkage
#
IF (UNIX)
IF (APPLE)
## ---- MAC OS ---- ##
## ---------------- ##
ELSE (APPLE)
## ---- LINUX ---- ##
# possible paths for: 'libMBproj_symbolicR.a'
SET(TRIAL_PATHS_LIB_PROJ_SYMB
"${PROJECT_SOURCE_DIR}/../symbolicR/build"
)
find_library (LIB_PROJ_SYMB libMBproj_symbolicR.a ${TRIAL_PATHS_LIB_PROJ_SYMB})
## --------------- ##
ENDIF (APPLE)
ELSE (UNIX)
## ---- WINDOWS ---- ##
ENDIF (UNIX)
# flag put to 1 if all required files are found
if ( LIB_PROJ_SYMB )
SET(PROJ_SYMB_FOUND 1)
else ( )
SET(PROJ_SYMB_FOUND 0)
endif ( )
# outputs
MARK_AS_ADVANCED(
PROJ_SYMB_FOUND
)
Markdown is supported
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