Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add tests for isendrecv and isendrecv_replace
[simgrid.git] / docs / source / Start_your_own_project.rst
index cb70ef0..bb06f09 100644 (file)
@@ -1,4 +1,4 @@
-..
+.. _setup_your_own:
 
 Start your Own Project
 ======================
 
 Start your Own Project
 ======================
@@ -24,15 +24,16 @@ to the template itself.
 Building your project with CMake
 --------------------------------
 
 Building your project with CMake
 --------------------------------
 
-Here is a `CMakeLists.txt` that you can use as a starting point for
-your project. It builds two simulators from a given set of source files.
+Here is a `CMakeLists.txt` that you can use as a starting point for your S4U
+project (see below for MPI projects). It builds two simulators from a given set
+of source files.
 
 .. code-block:: cmake
 
 
 .. code-block:: cmake
 
-   cmake_minimum_required(VERSION 2.8.8)
+   cmake_minimum_required(VERSION 2.8.12)
    project(MyFirstSimulator)
 
    project(MyFirstSimulator)
 
-   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
+   set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")
 
    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
    find_package(SimGrid REQUIRED)
 
    set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}/cmake/Modules/")
    find_package(SimGrid REQUIRED)
@@ -57,14 +58,33 @@ manually but your project will produce relevant error messages when
 trying to compile on a machine where SimGrid is not installed. Please
 also refer to the file header for more information.
 
 trying to compile on a machine where SimGrid is not installed. Please
 also refer to the file header for more information.
 
-MPI projects should include ``find_package (MPI)`` in CMakeLists.txt. Then, the
-variables ``MPI_C_COMPILER``, ``MPI_CXX_COMPILER``, and ``MPI_Fortran_COMPILER`` should
-point to the full path of smpicc, smpicxx, and smpiff respectively. Example:
+MPI projects should NOT search for MPI as usual in cmake, but instead use the ``smpi_c_target()`` macro
+to declare that a given target is meant to be executed in ``smpirun`` (which path is set in ``${SMPIRUN}``).
+This macro should work for C and C++ programs. Here is a small example:
 
 
-.. code-block:: console
+.. code-block:: cmake
+
+   # Search FindSimgrid in my sources
+   set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} "${CMAKE_SOURCE_DIR}")
+   find_package(SimGrid)
+
+   # Declare an executable, and specify that it's meant to run within smpirun
+   add_executable(roundtrip roundtrip.c)
+   smpi_c_target(roundtrip)
+
+   # Declare a test running our executable in ${SMPIRUN}
+   enable_testing()
+   add_test(NAME RoundTrip
+            COMMAND ${SMPIRUN} -platform ${CMAKE_SOURCE_DIR}/../cluster_backbone.xml -np 2 ./roundtrip)
+
+To compile Fortran code with cmake, you must override the ``MPI_Fortran_COMPILER`` variable as follows, but it will probably
+break some configuration checks, so you should export ``SMPI_PRETEND_CC=1`` during the configuration (not during the compilation
+nor the execution).
 
 
-   $ cmake -DMPI_C_COMPILER=/opt/simgrid/bin/smpicc -DMPI_CXX_COMPILER=/opt/simgrid/bin/smpicxx -DMPI_Fortran_COMPILER=/opt/simgrid/bin/smpiff .
+.. code-block:: console
 
 
+   $ SMPI_PRETEND_CC=1 cmake -DMPI_C_COMPILER=/opt/simgrid/bin/smpicc -DMPI_CXX_COMPILER=/opt/simgrid/bin/smpicxx -DMPI_Fortran_COMPILER=/opt/simgrid/bin/smpiff .
+   $ make
 
 Building your project with Makefile
 -----------------------------------
 
 Building your project with Makefile
 -----------------------------------
@@ -121,33 +141,12 @@ Develop in C++ with Eclipse
 If you wish to develop your plugin or modify SimGrid using
 Eclipse. You have to run cmake and import it as a Makefile project.
 
 If you wish to develop your plugin or modify SimGrid using
 Eclipse. You have to run cmake and import it as a Makefile project.
 
-Next, you have to activate C++14 in your build settings, add -std=c++14
+Next, you have to activate C++17 in your build settings, add -std=c++17
 in the CDT GCC Built-in compiler settings.
 
 .. image:: /img/eclipseScreenShot.png
    :align: center
 
 in the CDT GCC Built-in compiler settings.
 
 .. image:: /img/eclipseScreenShot.png
    :align: center
 
-
-Building the Java examples in Eclipse
--------------------------------------
-
-If you want to build our Java examples in Eclipse, get the whole
-source code and open the archive on your disk. In Eclipse, select
-the menu "File / Import", and then in the wizard "General / Existing
-Project into Workspace". On the next page, select the directory
-"examples/deprecated/java" that you can find in the SimGrid source tree as a root
-directory and finish the creation.
-
-The file ``simgrid.jar`` must be in the root directory of the SimGrid
-tree. That's where it is built by default, but if you don't want to
-compile it yourself, just grab that file from the SimGrid website and
-copy it in here.
-
-Please note that once you better understand SimGrid, you should not
-modify the examples directly but instead create your own project in
-eclipse. This will make it easier to upgrade to another version of
-SimGrid.
-
 .. _install_yours_troubleshooting:
 
 Troubleshooting your Project Setup
 .. _install_yours_troubleshooting:
 
 Troubleshooting your Project Setup
@@ -178,7 +177,6 @@ Many undefined references
 .. code-block:: console
 
   masterworker.c:209: undefined reference to `sg_version_check'
 .. code-block:: console
 
   masterworker.c:209: undefined reference to `sg_version_check'
-  masterworker.c:209: undefined reference to `MSG_init_nocheck'
   (and many other undefined references)
 
 This happens when the linker tries to use the wrong library. Use
   (and many other undefined references)
 
 This happens when the linker tries to use the wrong library. Use