Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
23960e93134ecbebc4e6eb9d46f16b8489d0fff1
[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 foreach(target "${TARGET_NAME}")
41     add_executable(${target} "${target}.c")
42     message(STATUS "source_file: ${target}.c")
43     message(STATUS "target name: ${target}.exe")
44     # Any targets need to be linked with simgrid and pcre
45     target_link_libraries(${target} simgrid pcre pthread ws2_32) 
46 endforeach(target ${SOURCE_FILE})