Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
6fd3310944c2dc3d4f4339a721ec4ecdd0c7fca7
[simgrid.git] / doc / HelloWorld / CMakeLists.txt
1 ### This is a template for building targets with simgrid
2 cmake_minimum_required(VERSION 2.8)
3
4 ### Need to set rc ccompiler before enable language
5 if(WIN32)
6     SET(CMAKE_RC_COMPILER "windres")
7 endif(WIN32)
8
9 project(MY_SIMGRID_PROJECT C)
10
11 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
12 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
13
14 ###############################
15 # Test the build dependencies #
16 ###############################
17 include(FindPCRE.cmake)
18 message(STATUS "Looking for lib Simgrid")
19 if("$ENV{SIMGRID_ROOT}" STREQUAL "")
20     message(STATUS "Looking for lib Simgrid - Not found")
21     message(FATAL_ERROR "Simgrid not found, reinstall it or set SIMGRID_ROOT")
22 else("$ENV{SIMGRID_ROOT}" STREQUAL "")
23     link_directories($ENV{SIMGRID_ROOT}/lib)
24     include_directories($ENV{SIMGRID_ROOT}/include)
25     include_directories($ENV{SIMGRID_ROOT}/src)
26     include_directories($ENV{SIMGRID_ROOT}/src/include)
27     add_library(libsimgrid STATIC IMPORTED)
28     message(STATUS "Looking for lib Simgrid - found") 
29 endif("$ENV{SIMGRID_ROOT}" STREQUAL "")
30
31 ################
32 # FIND TARGETS #
33 ################
34 file(GLOB SOURCE_FILE
35 RELATIVE ${CMAKE_HOME_DIRECTORY}/
36 "*.c"
37 )
38 string(REPLACE ".c" "" TARGET_NAME ${SOURCE_FILE})
39
40 #########################
41 # add_executable        #
42 #    args1 target name  #
43 #    args2 sources      #
44 #########################
45 foreach(target "${TARGET_NAME}")
46     add_executable(${target} "${target}.c")
47     message(STATUS "source_file: ${target}.c")
48     message(STATUS "target name: ${target}.exe")
49     # Any targets need to be linked with simgrid and pcre
50     target_link_libraries(${target} simgrid pcre) 
51 endforeach(target ${SOURCE_FILE})