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

clean cmake calls

parent f9605644
......@@ -34,7 +34,7 @@ if (UNIX)
set(CMAKE_C_FLAGS "-g -Wall -Wno-unused-but-set-variable -Wno-unused-variable -Wno-comment")
# remove some compilation warnings (This line should be removed once the loading, equil and modal modules are stabilized)
set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-uninitialized -Wno-unused-result -Wno-maybe-uninitialized")
endif (UNIX)
endif ( )
# add additional CMakeLists.txt files
set(CMAKE_AUX ${ROBOTRAN_SOURCE_DIR}/cmake_aux)
......@@ -56,45 +56,6 @@ release_debug()
definitions()
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# EXTERNAL LIBRARIES
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
## --- WIN32 or WIN64 DETECTION --- ##
if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) # 64bit windows
SET(WIN_LIB_DIRECTORY win64_include_lib)
else( CMAKE_SIZEOF_VOID_P EQUAL 8 ) # 32bit windows
SET(WIN_LIB_DIRECTORY win32_include_lib)
endif( CMAKE_SIZEOF_VOID_P EQUAL 8 )
## ---- WINDOWS DLL FILES ---- ##
# copy all the dll (except 'jvm.dll') used for Windows
# these dll files are copied in the Executable directory (Debug or Release)
if (WIN32)
file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${CMAKE_BINARY_DIR}/Debug)
file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${CMAKE_BINARY_DIR}/Release)
endif (WIN32)
set(CMAKE_MODULE_PATH ${ROBOTRAN_SOURCE_DIR}/conf)
# Libxml2
xml_lib()
# GSL
gsl_lib()
# SDL
if (FLAG_PLOT)
sdl_lib()
endif (FLAG_PLOT)
# JAVA
if (FLAG_VISU)
java_lib()
endif (FLAG_VISU)
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# USER ABSOLUTE PATHS
......@@ -131,6 +92,36 @@ init_include()
increment_include("${PROJECT_SOURCE_DIR}/..")
increment_include("${ROBOTRAN_SOURCE_DIR}")
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# EXTERNAL LIBRARIES
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
## --- WIN32 or WIN64 DETECTION --- ##
if( CMAKE_SIZEOF_VOID_P EQUAL 8 ) # 64bit windows
SET(WIN_LIB_DIRECTORY win64_include_lib)
else( CMAKE_SIZEOF_VOID_P EQUAL 8 ) # 32bit windows
SET(WIN_LIB_DIRECTORY win32_include_lib)
endif( )
## ---- WINDOWS DLL FILES ---- ##
# copy all the dll (except 'jvm.dll') used for Windows
# these dll files are copied in the Executable directory (Debug or Release)
if (WIN32)
file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${CMAKE_BINARY_DIR}/Debug)
file(COPY ${ROBOTRAN_SOURCE_DIR}/${WIN_LIB_DIRECTORY}/dll/ DESTINATION ${CMAKE_BINARY_DIR}/Release)
endif ( )
set(CMAKE_MODULE_PATH ${ROBOTRAN_SOURCE_DIR}/conf)
# GSL
gsl_lib(project)
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
# CONFIGURE EXECUTABLE
# * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
......@@ -144,38 +135,38 @@ set (Executable exe_${PROJECT_NAME})
# generate the executable
add_executable (${Executable} ${SOURCE_FILES})
if (FLAG_SEPARATE_BUILD)
#Find MBSysC dynamic libraries
if (FLAG_SEPARATE_BUILD) # find MBSysC dynamic libraries
find_package(LibRobotranC REQUIRED)
target_link_libraries(${Executable} "${LIB_MBSYSC_MODULES}")
target_link_libraries(${Executable} "${LIB_MBSYSC_LOAD}")
target_link_libraries(${Executable} "${LIB_MBSYSC_UTILITIES}")
else (FLAG_SEPARATE_BUILD)
else ( )
add_subdirectory("${ROBOTRAN_SOURCE_DIR}/mbs_common" "${CMAKE_CURRENT_BINARY_DIR}/mbs_common")
target_link_libraries(${Executable} MBsysC_loadXML)
target_link_libraries(${Executable} MBsysC_module)
if(NOT FLAG_SHARED_LIB)
target_link_libraries(${Executable} MBsysC_struct MBsysC_numerics MBsysC_utilities MBsysC_realtime)
endif(NOT FLAG_SHARED_LIB)
endif ( )
endif (FLAG_SEPARATE_BUILD)
if (FLAG_VISU)
include_directories(${JNI_INCLUDE_PATH})
endif (FLAG_VISU)
# math external library (for Unix): linkage
if (UNIX)
target_link_libraries (${Executable} m)
endif (UNIX)
endif ( )
#Libxml2 and GSL external libraries: linkage
target_link_libraries (${Executable} ${LIBXML2_LIBRARIES} ${GSL_LIBRARIES})
# SDL external library: linkage
if (FLAG_PLOT)
target_link_libraries (${Executable} ${SDL2_LIBRARIES})
target_link_libraries (${Executable} ${SDL2TTF_LIBRARIES})
endif (FLAG_PLOT)
target_link_libraries (${Executable} ${SDL2_LIBRARIES} ${SDL2TTF_LIBRARIES})
endif ( )
# Java external library: linkage
if (FLAG_VISU)
target_link_libraries (${Executable} ${JNI_LIBRARIES})
endif (FLAG_VISU)
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);
......
# Libxml2
function(xml_lib)
function(xml_lib arg0)
add_definitions( -DXML )
find_package(Libxml2 REQUIRED)
if (LIBXML2_FOUND)
include_directories (${LIBXML2_INCLUDE_PATH})
message( "\n >> Libxml2 found")
message( "\n >> ${arg0}: Libxml2 found")
else ( )
message( "\n >> Libxml2 not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindLibxml2.cmake")
message( "\n >> ${arg0}: Libxml2 not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindLibxml2.cmake")
endif ( )
message(" -> INC : ${LIBXML2_INCLUDE_PATH}")
......@@ -17,12 +17,12 @@ function(xml_lib)
endfunction()
# GSL
function(gsl_lib)
function(gsl_lib arg0)
find_package(GSL REQUIRED)
if (GSL_FOUND)
message( "\n >> GSL found")
message( "\n >> ${arg0}: GSL found")
else ( )
message( "\n >> GSL not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindGSL.cmake")
message( "\n >> ${arg0}: GSL not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindGSL.cmake")
endif ( )
message(" -> INC : ${GSL_INCLUDE_DIR}")
......@@ -32,13 +32,13 @@ function(gsl_lib)
endfunction()
# SDL
function(sdl_lib)
function(sdl_lib arg0)
find_package(SDL2 REQUIRED)
if (SDL2_FOUND)
include_directories (${SDL2_INCLUDE_PATH})
message( "\n >> SDL 2.0 found")
message( "\n >> ${arg0}: SDL 2.0 found")
else ( )
message( "\n>> SDL 2.0 not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindSDL2.cmake")
message( "\n >> ${arg0}: SDL 2.0 not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindSDL2.cmake")
endif ( )
message(" -> INC : ${SDL2_INCLUDE_PATH}")
......@@ -48,9 +48,9 @@ function(sdl_lib)
find_package(SDL2_ttf REQUIRED)
if (SDL2TTF_FOUND)
include_directories (${SDL2TTF_INCLUDE_PATH})
message( "\n >> SDL 2.0 ttf found")
message( "\n >> ${arg0}: SDL 2.0 ttf found")
else ( )
message( "\n >> SDL 2.0 ttf not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindSDL2_ttf.cmake")
message( "\n >> ${arg0}: SDL 2.0 ttf not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindSDL2_ttf.cmake")
endif ( )
message(" -> INC : ${SDL2TTF_INCLUDE_PATH}")
......@@ -62,13 +62,13 @@ endfunction()
# Java
function(java_lib)
function(java_lib arg0)
find_package(JNI REQUIRED)
if (JNI_FOUND)
include_directories (${JNI_INCLUDE_PATH})
message( "\n >> JNI found")
message( "\n >> ${arg0}: JNI found")
else ( )
message( "\n >> JNI not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindJNI.cmake")
message( "\n >> ${arg0}: JNI not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindJNI.cmake")
endif ( )
message(" -> INC : ${JNI_INCLUDE_PATH}")
......@@ -76,15 +76,15 @@ function(java_lib)
# Java 3D
find_package(J3D REQUIRED)
if (J3D_FOUND)
# path to some Java 3D files (to print in 'cmake_config.h')
set (J3D_PATH ${J3D_PATH} PARENT_SCOPE)
message( "\n >> Java 3D found")
if (J3D_FOUND)
message( "\n >> ${arg0}: Java 3D found")
else ( )
message( "\n >> Java 3D not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindJ3D.cmake")
message( "\n >> ${arg0}: Java 3D not found, modify ${ROBOTRAN_SRC_COMMON}/conf/FindJ3D.cmake")
endif ( )
message(" -> PATH : ${J3D_PATH}\n")
set(JNI_INCLUDE_PATH ${JNI_INCLUDE_PATH} PARENT_SCOPE)
set(JNI_LIBRARIES ${JNI_LIBRARIES} PARENT_SCOPE)
set (J3D_PATH ${J3D_PATH} PARENT_SCOPE)
endfunction()
......@@ -37,6 +37,7 @@ add_subdirectory (${CMAKE_AUX}/libraries/ ${CMAKE_AUX_BIN}/libraries/)
# Libxml2
xml_lib()
set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} PARENT_SCOPE)
# function to list all source files in the src/ directory,
# recursing into sub-directories
......
......@@ -24,6 +24,7 @@ flags_check()
## --------------- ##
if (UNIX)
set(CMAKE_C_FLAGS "-fPIC")
set(CMAKE_EXE_LINKER_FLAGS "-fPIC")
......@@ -34,4 +35,13 @@ add_subdirectory (mbs_struct/ ${CMAKE_CURRENT_BINARY_DIR}/mbs_struct/)
add_subdirectory (mbs_utilities/ ${CMAKE_CURRENT_BINARY_DIR}/mbs_utilities/)
add_subdirectory (mbs_load_xml/ ${CMAKE_CURRENT_BINARY_DIR}/mbs_load_xml/)
add_subdirectory (mbs_module/ ${CMAKE_CURRENT_BINARY_DIR}/mbs_module/)
add_subdirectory (mbs_realtime/ ${CMAKE_CURRENT_BINARY_DIR}/mbs_realtime/)
\ No newline at end of file
add_subdirectory (mbs_realtime/ ${CMAKE_CURRENT_BINARY_DIR}/mbs_realtime/)
# add parent scope
set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} PARENT_SCOPE)
set(GSL_LIBRARIES ${GSL_LIBRARIES} PARENT_SCOPE)
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} PARENT_SCOPE)
set(SDL2TTF_LIBRARIES ${SDL2TTF_LIBRARIES} PARENT_SCOPE)
set(JNI_INCLUDE_PATH ${JNI_INCLUDE_PATH} PARENT_SCOPE)
set(JNI_LIBRARIES ${JNI_LIBRARIES} PARENT_SCOPE)
set (J3D_PATH ${J3D_PATH} PARENT_SCOPE)
......@@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 2.8.7)
project(MBsysC_loadXML)
# Libxml2
xml_lib()
xml_lib(mbs_load_xml)
set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} PARENT_SCOPE)
# list source files to compile
init_src()
......
......@@ -7,7 +7,8 @@ cmake_minimum_required(VERSION 2.8.7)
project(MBsysC_module)
# Libxml2
xml_lib()
xml_lib(mbs_module)
set(LIBXML2_LIBRARIES ${LIBXML2_LIBRARIES} PARENT_SCOPE)
# list source files to compile
init_src()
......
......@@ -14,7 +14,9 @@ increment_src(./realtime)
if (FLAG_PLOT)
# Find SDL
sdl_lib()
sdl_lib(mbs_realtime)
set(SDL2_LIBRARIES ${SDL2_LIBRARIES} PARENT_SCOPE)
set(SDL2TTF_LIBRARIES ${SDL2TTF_LIBRARIES} PARENT_SCOPE)
increment_src(./sdl)
......@@ -22,17 +24,20 @@ if (FLAG_PLOT)
set(SDL_FILES ${CMAKE_CURRENT_SOURCE_DIR}/sdl/SDL_files)
configure_file (
"./sdl/conf/cmake_sdl_config.h.in"
"${PROJECT_BINARY_DIR}/conf/cmake_sdl_config.h"
)
include_directories ("${PROJECT_BINARY_DIR}/conf")
"./sdl/conf/cmake_sdl_config.h.in"
"${PROJECT_BINARY_DIR}/conf/cmake_sdl_config.h"
)
include_directories ("${PROJECT_BINARY_DIR}/conf")
endif (FLAG_PLOT)
# Get java lib and add java functions to src
if (FLAG_VISU)
# find java and java 3d
java_lib()
java_lib(mbs_realtime)
set(JNI_INCLUDE_PATH ${JNI_INCLUDE_PATH} PARENT_SCOPE)
set(JNI_LIBRARIES ${JNI_LIBRARIES} PARENT_SCOPE)
set (J3D_PATH ${J3D_PATH} PARENT_SCOPE)
include_directories("./java")
increment_src(./java)
......@@ -40,10 +45,10 @@ if (FLAG_VISU)
set(JAR_PATH ${CMAKE_CURRENT_SOURCE_DIR}/../../mbsyspad/MBsysPad.jar)
configure_file (
"./java/conf/cmake_java_config.h.in"
"${PROJECT_BINARY_DIR}/conf/cmake_java_config.h"
)
include_directories ("${PROJECT_BINARY_DIR}/conf")
"./java/conf/cmake_java_config.h.in"
"${PROJECT_BINARY_DIR}/conf/cmake_java_config.h"
)
include_directories ("${PROJECT_BINARY_DIR}/conf")
endif (FLAG_VISU)
......
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