Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Cosmetics
[simgrid.git] / doc / HelloWorld / CMakeLists.txt
index cfeb963..a74538d 100644 (file)
@@ -4,9 +4,13 @@ cmake_minimum_required(VERSION 2.8)
 ### Need to set rc ccompiler before enable language
 if(WIN32)
     SET(CMAKE_RC_COMPILER "windres")
+    set(LIBRARIES_DEP simgrid pcre ws2_32 pthread)
+else(WIN32)
+    set(LIBRARIES_DEP simgrid pcre pthread)
 endif(WIN32)
 
-project(HelloWorld C)
+project(MY_SIMGRID_PROJECT C)
+
 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
 
@@ -23,19 +27,22 @@ else("$ENV{SIMGRID_ROOT}" STREQUAL "")
     include_directories($ENV{SIMGRID_ROOT}/include)
     include_directories($ENV{SIMGRID_ROOT}/src)
     include_directories($ENV{SIMGRID_ROOT}/src/include)
-    add_library(libsimgrid STATIC IMPORTED)
     message(STATUS "Looking for lib Simgrid - found") 
 endif("$ENV{SIMGRID_ROOT}" STREQUAL "")
 
-###########
-# TARGETS #
-###########
+################
+# FIND TARGETS #
+################
+file(GLOB SOURCE_FILE
+RELATIVE ${CMAKE_HOME_DIRECTORY}/
+"*.c"
+)
+string(REPLACE ".c" "" TARGET_NAME ${SOURCE_FILE})
 
-#########################
-# add_executable        #
-#    args1 target name  #
-#    args2 sources      #
-#########################
-add_executable(HelloWorld HelloWorld.c)
-# Any targets need to be linked with simgrid and pcre
-target_link_libraries(HelloWorld simgrid pcre) 
+foreach(target "${TARGET_NAME}")
+    add_executable(${target} "${target}.c")
+    message(STATUS "source_file: ${target}.c")
+    message(STATUS "target name: ${target}.exe")
+    # Any targets need to be linked with libraries
+    target_link_libraries(${target} ${LIBRARIES_DEP})
+endforeach(target ${SOURCE_FILE})