SimGrid
3.7
Scalable simulation of distributed systems
|
CMake is a family of tools designed to build, test and package software. CMake is used to control the software compilation process using simple platform and compiler independent configuration files. CMake generates native makefiles and workspaces that can be used in the compiler environment of your choice. For more information see official web site here.
CMake permits to developers to compil projects on different plateforms. Then many tools are embedded like ctest for making test, a link to cdash for vizualise results but also test coverage and bug reports.
CMake needs some prerequists like :
For Unix and MacOS:
For Windows :
"cmake -D[name]=[value] ... ./" [name] enable_gtnets [value] ON/OFF or TRUE/FALSE or 1/0 enable_ns3 ON/OFF or TRUE/FALSE or 1/0 enable_lua ON/OFF or TRUE/FALSE or 1/0 enable_compile_optimizations ON/OFF or TRUE/FALSE or 1/0 enable_compile_warnings ON/OFF or TRUE/FALSE or 1/0 enable_smpi ON/OFF or TRUE/FALSE or 1/0 enable_maintainer_mode ON/OFF or TRUE/FALSE or 1/0 enable_tracing ON/OFF or TRUE/FALSE or 1/0 enable_coverage ON/OFF or TRUE/FALSE or 1/0 enable_memcheck ON/OFF or TRUE/FALSE or 1/0 enable_model-checking ON/OFF or TRUE/FALSE or 1/0 enable_debug ON/OFF or TRUE/FALSE or 1/0 enable_jedule ON/OFF or TRUE/FALSE or 1/0 enable_latency_bound_tracking ON/OFF or TRUE/FALSE or 1/0 enable_lib_static ON/OFF or TRUE/FALSE or 1/0 enable_supernovae ON/OFF or TRUE/FALSE or 1/0 enable_msg_deprecated ON/OFF or TRUE/FALSE or 1/0 enable_print_message ON/OFF or TRUE/FALSE or 1/0 custom_flags <flags> gtnets_path <path_to_gtnets_directory> ns3_path <path_to_ns3_directory> CMAKE_INSTALL_PREFIX <path_to_install_directory> CMAKE_C_COMPILER <path_to_compiler> CMAKE_CXX_COMPILER <path_to_compiler> pipol_user <pipol_username>
Those options are initialized the first time you launch "cmake ." whithout specified option.
enable_gtnets on enable_lua on enable_smpi on enable_tracing on enable_compile_optimizations on enable_debug on enable_compile_warnings off enable_maintainer_mode off enable_coverage off enable_memcheck off enable_model-checking off enable_jedule off enable_latency_bound_tracking off enable_lib_static off CMAKE_INSTALL_PREFIX /usr/local custom_flags null gtnets_path null pipol_user null
When options have been set they are keep into a cache file named "CMakeCache.txt". So if you want reset values you just delete this file located to the project directory.
On Unix or Mac platform:
cmake -D[name]=[value] ... ./ make
On Windows platform:
cmake -G"MinGW Makefiles" -D[name]=[value] ... ./ mingw32-make
"ccmake ./"
Then follow instructions.
As cmake generate many files used for compilation, we recommand to make a build directory. For examples you can make :
"navarrop@caraja:~/Developments$ cd simgrid/" "navarrop@caraja:~/Developments/simgrid$ mkdir build_directory" "navarrop@caraja:~/Developments/simgrid$ cd build_directory/" "navarrop@caraja:~/Developments/simgrid/build_directory$ cmake ../" "navarrop@caraja:~/Developments/simgrid/build_directory$ make"
Or complety out of sources :
"navarrop@caraja:~/Developments$ mkdir build_dir" "navarrop@caraja:~/Developments$ cd build_dir/" "navarrop@caraja:~/Developments/build_dir$ cmake ../simgrid/" "navarrop@caraja:~/Developments/build_dir$ make"
Those two kind of compilation permit to delete files created by compilation easier.
cmake <path> configure the project for Unix and Mac cmake -G"MinGW Makefiles" <path> configure the project for Windows make build all targets for Unix and Mac ming32-make buill all targets for windows (g)make VERBOSE=1 build all targets and print build command lines make check test all targets and summarize make dist make the distrib make distcheck check the dist (make + make dist + make check) (g)make install install the project (doc/ bin/ lib/ include/) (g)make uninstall uninstall the project (doc/ bin/ lib/ include/) (g)make clean clean all targets make simgrid_documentation Create simgrid documentation
When the project have been succesfully compiling and build you can make tests.
ctest launch only tests ctest -D Continuous ctest -D Continuous(Start|Update|Configure|Build) ctest -D Continuous(Test|Coverage|MemCheck|Submit) ctest -D Experimental ctest -D Experimental(Start|Update|Configure|Build) ctest -D Experimental(Test|Coverage|MemCheck|Submit) ctest -D Nightly ctest -D Nightly(Start|Update|Configure|Build) ctest -D Nightly(Test|Coverage|MemCheck|Submit) ctest -D NightlyMemoryCheck
If you want to test before make a commit you can simply make "ctest -D Experimental" and then you can visualize results submitted into Cdash. (Go to Cdash site).
git clone git://scm.gforge.inria.fr/simgrid/simgrid.git simgrid cd simgrid cmake -Denable_maintainer_mode=on -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./ make make install
wget https://gforge.inria.fr/frs/download.php/28674/simgrid-3.6.1.tar.gz tar xf simgrid-3.6.1.tar.gz cd simgrid-3.6.1 cmake -DCMAKE_INSTALL_PREFIX=/home/navarrop/Bureau/install_simgrid ./ make make install
If you want make an executable you have to create a CMakeList.txt to the src directory. You must specified where to create the executable, source list, dependencies and the name of the binary.
cmake_minimum_required(VERSION 2.6) set(EXECUTABLE_OUTPUT_PATH "./") set(LIBRARY_OUTPUT_PATH "${CMAKE_HOME_DIRECTORY}/lib") add_executable(get_sender get_sender.c) #add_executable(<name_of_target> <src list>) ### Add definitions for compile target_link_libraries(get_sender simgrid m pthread) #target_link_libraries(<name_of_targe> <dependencies>)
Then you have to modified <project/directory>/buildtools/Cmake/MakeExeLib.cmake and add this line :
add_subdirectory(${CMAKE_HOME_DIRECTORY}/<path_where_is_CMakeList.txt>)
If you want modified, add or delete source files from a library you have to edit <project/directory>/buildtools/Cmake/DefinePackages.cmake
set(JMSG_JAVA_SRC ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgException.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/JniException.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/NativeException.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/HostNotFoundException.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ProcessNotFoundException.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Msg.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Process.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Host.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Task.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/MsgNative.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/ApplicationHandler.java ${CMAKE_HOME_DIRECTORY}/src/java/simgrid/msg/Sem.java )
Before start the installation, you need to be sure to have the following dependencies:
Then download the package SimGrid Installer, execute it and follow instructions.
Step 1: Accept the license.
Step 2: Select packets to install.
Step 3: Choice where to install packets previously selected. Please don't use spaces in path.
Step 4: Add CLASSPATH to environment variables.
Step 5: Add PATH to environment variables.
Step 6: Restart your computer to take in consideration environment variables.
In the SimGrid install directroy you should have an HelloWorld project to explain you how to start compiling a source file. There are:
- HelloWorld.c The example source file. - CMakeLists.txt It allows to configure the project. - FindPCRE.cmake This finds and links to the pcre library (Normally included into Simgrid directory "GnuWin32"). - README This explaination.
Now let's compil this example:
For compiling your own code you can simply copy the HelloWorld project and rename source name. It will create a target with the same name of the source.
################ # FIND TARGETS # ################ add_executable(TARGET_NAME SOURCES) #It creates a target called 'TARGET_NAME.exe' with the sources 'SOURCES' target_link_libraries(TARGET_NAME simgrid pcre) #Links TARGET_NAME with simgrid and pcre
cmake -G"MinGW Makefiles" \<path_to_HelloWorld_project\>
Allan Espinosa made these set of Vagrant rules available so that you can use the SimGrid Ruby bindings in a virtual machine using VirtualBox. Thanks to him for that. You can find his project here: https://github.com/aespinosa/simgrid-vagrant
Do not build your simulator by modifying the SimGrid examples. Go outside the SimGrid source tree and create your own working directory (say /home/joe/SimGrid/MyFirstScheduler/
).
Suppose your simulation has the following structure (remember it is just an example to illustrate a possible way to compile everything; feel free to organize it as you want).
sched.h
: a description of the core of the scheduler (i.e. which functions are can be used by the agents). For example we could find the following functions (master, forwarder, slave).sched.c
: a C file including sched.h
and implementing the core of the scheduler. Most of these functions use the MSG functions defined in section Task Actions.masterslave.c
: a C file with the main function, i.e. the MSG initialization (MSG_global_init()), the platform creation (e.g. with MSG_create_environment()), the deployment phase (e.g. with MSG_function_register() and MSG_launch_application()) and the call to MSG_main()).To compile such a program, we suggest to use the following Makefile. It is a generic Makefile that we have used many times with our students when we teach the C language.
all: masterslave masterslave: masterslave.o sched.o INSTALL_PATH = $$HOME CC = gcc PEDANTIC_PARANOID_FREAK = -O0 -Wshadow -Wcast-align \ -Waggregate-return -Wmissing-prototypes -Wmissing-declarations \ -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations \ -Wmissing-noreturn -Wredundant-decls -Wnested-externs \ -Wpointer-arith -Wwrite-strings -finline-functions REASONABLY_CAREFUL_DUDE = -Wall NO_PRAYER_FOR_THE_WICKED = -w -O2 WARNINGS = $(REASONABLY_CAREFUL_DUDE) CFLAGS = -g $(WARNINGS) INCLUDES = -I$(INSTALL_PATH)/include DEFS = -L$(INSTALL_PATH)/lib/ LDADD = -lm -lsimgrid LIBS = %: %.o $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) $^ $(LIBS) $(LDADD) -o $@ %.o: %.c $(CC) $(INCLUDES) $(DEFS) $(CFLAGS) -c -o $@ $< clean: rm -f $(BIN_FILES) *.o *~ .SUFFIXES: .PHONY : clean
The first two lines indicates what should be build when typing make (masterslave
) and of which files it is to be made of (masterslave.o
and sched.o
). This makefile assumes that you have set up correctly your LD_LIBRARY_PATH
variable (look, there is a LDADD = -lm -lsimgrid
). If you prefer using the static version, remove the -lsimgrid
and add a /lib/libsimgrid.a
on the next line, right after the LIBS =
.
More generally, if you have never written a Makefile by yourself, type in a terminal : info make
and read the introduction. The previous example should be enough for a first try but you may want to perform some more complex compilations...
If you use the GRAS interface instead of the MSG one, then previous section is not the better source of information. Instead, you should check the GRAS tutorial in general, and the Lesson 1: Setting up your own project in particular.
Back to the main Simgrid Documentation page |
The version of SimGrid documented here is v3.7. Documentation of other versions can be found in their respective archive files (directory doc/html). |
Generated by ![]() |