Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Look for simgrid into $SIMGRID_ROOT. If lib simgrid or gras.h is not found print...
[simgrid.git] / CMakeLists.txt
index 74da829..be2d4bf 100644 (file)
@@ -1,37 +1,42 @@
 cmake_minimum_required(VERSION 2.8)
-project(simgrid-java C)
+project(SimGrid-Java C)
 set(UPDATE_TYPE svn)
 set(CMAKE_C_FLAGS "" CACHE TYPE INTERNAL FORCE)
 set(CMAKE_EXE_LINKER_FLAGS "" CACHE TYPE INTERNAL FORCE)
 set(CMAKE_LIBRARY_OUTPUT_DIRECTORY "${CMAKE_HOME_DIRECTORY}/lib")
 set(soversion 1)
 
+set(SIMGRID_JAVA_VERSION_MAJOR "1")
+set(SIMGRID_JAVA_VERSION_MINOR "0")
+set(SIMGRID_JAVA_VERSION_PATCH "0")
+set(DIST_NAME ${PROJECT_NAME}-${SIMGRID_JAVA_VERSION_MAJOR}.${SIMGRID_JAVA_VERSION_MINOR})
+
+########
+## GCC #
+########
+exec_program("${CMAKE_C_COMPILER} --version" OUTPUT_VARIABLE "COMPILER_C_VERSION")
+string(REGEX MATCH "[0-9].[0-9].[0-9]" COMPILER_C_VERSION "${COMPILER_C_VERSION}")
+string(REGEX MATCH "^[0-9].[0-9]" COMPILER_C_VERSION_MAJOR_MINOR "${COMPILER_C_VERSION}")
+string(REPLACE "${COMPILER_C_VERSION_MAJOR_MINOR}." "" COMPILER_C_VERSION_PATCH "${COMPILER_C_VERSION}")
+
 ########
-## SVN #
+## GIT #
 ########
-if(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
-       find_file(SVN ".svn" ${CMAKE_HOME_DIRECTORY})
-       exec_program("svnversion ${CMAKE_HOME_DIRECTORY}" OUTPUT_VARIABLE "SVN_VERSION")
-endif(IS_DIRECTORY ${CMAKE_HOME_DIRECTORY}/.svn)
-
-exec_program("git config --get svn-remote.svn.url"
-       OUTPUT_VARIABLE url
-       RETURN_VALUE ret)
-if(ret EQUAL 0)
-       exec_program("git svn info" ${CMAKE_HOME_DIRECTORY}
-               OUTPUT_VARIABLE "GIT_SVN_VERSION")
-       string(REPLACE "\n" ";" GIT_SVN_VERSION ${GIT_SVN_VERSION})
-       foreach(line ${GIT_SVN_VERSION})
-               string(REGEX MATCH "^Revision:.*" line_good ${line})
-               if(line_good)
-                       string(REPLACE "Revision: " ""
-                               line_good ${line_good})
-                       set(SVN_VERSION ${line_good})
-               endif(line_good)
-       endforeach(line ${GIT_SVN_VERSION})
-endif(ret EQUAL 0)
-
-message(STATUS "Svn version : ${SVN_VERSION}")
+if(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
+exec_program("git remote | head -n 1" OUTPUT_VARIABLE remote RETURN_VALUE ret)
+exec_program("git config --get remote.${remote}.url" OUTPUT_VARIABLE url RETURN_VALUE ret)
+
+if(url)
+       exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log --oneline -1" OUTPUT_VARIABLE "GIT_VERSION")
+       message(STATUS "Git version: ${GIT_VERSION}")
+       exec_program("git --git-dir=${CMAKE_HOME_DIRECTORY}/.git log -n 1 --format=%ai ." OUTPUT_VARIABLE "GIT_DATE")
+       message(STATUS "Git date: ${GIT_DATE}")
+       string(REGEX REPLACE " .*" "" GIT_VERSION "${GIT_VERSION}")
+       STRING(REPLACE " +0000" "" GIT_DATE ${GIT_DATE})
+       STRING(REPLACE " " "~" GIT_DATE ${GIT_DATE})
+       STRING(REPLACE ":" "-" GIT_DATE ${GIT_DATE})
+endif(url)
+endif(EXISTS ${CMAKE_HOME_DIRECTORY}/.git/)
 
 #########
 # CDASH #
@@ -41,7 +46,7 @@ SET(DROP_SITE "cdash.inria.fr/CDash")
 SET(DROP_LOCATION "/submit.php?project=simgrid")
 SET(DROP_SITE_CDASH TRUE)
 SET(TRIGGER_SITE "http://cdash.inria.fr/CDash/cgi-bin/Submit-Random-TestingResults.cgi")
-SET(BUILDNAME "Simgrid-Java" CACHE TYPE INTERNAL FORCE)
+SET(BUILDNAME "SimGrid-Java" CACHE TYPE INTERNAL FORCE)
 set(osname ${CMAKE_SYSTEM_NAME})
 set(cpu ${CMAKE_SYSTEM_PROCESSOR})
 set(DISTRIB2 ${CMAKE_SYSTEM_VERSION})
@@ -122,6 +127,41 @@ set(JAVA_EXAMPLES
        examples/pingPong/Sender.java
        examples/pingPong/Receiver.java
        examples/pingPong/PingPongTest.java
+       examples/master_slave_bypass/Master.java
+       examples/master_slave_bypass/MsBypass.java
+       examples/master_slave_bypass/Slave.java
+       examples/master_slave_bypass/FinalizeTask.java
+       examples/master_slave_kill/Master.java
+       examples/master_slave_kill/MsKill.java
+       examples/master_slave_kill/Slave.java
+       examples/master_slave_kill/FinalizeTask.java
+)
+
+set(CMAKE_SRC
+${CMAKE_HOME_DIRECTORY}/ChangeLog
+${CMAKE_HOME_DIRECTORY}/CMakeLists.txt
+${CMAKE_HOME_DIRECTORY}/FindJavaSG.cmake
+${CMAKE_HOME_DIRECTORY}/FindSimGrid.cmake
+)
+
+set(XML_FILES
+    examples/commTime/commTimeDeployment.xml
+    examples/mutualExclusion/ring3.xml
+    examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
+    examples/platform.xml
+    examples/pingPong/pingPongDeployment.xml
+    examples/basic/basicDeployment.xml
+    examples/basic/deploy.xml
+    examples/master_slave_bypass/platform.xml
+    examples/master_slave_kill/platform.xml
+)
+
+set(source_to_pack
+${CMAKE_SRC}
+${JMSG_C_SRC}
+${JMSG_JAVA_SRC}
+${JAVA_EXAMPLES}
+${XML_FILES}
 )
 
 string(REPLACE "org/" "${CMAKE_HOME_DIRECTORY}/org/" JAVA_FILES "${JMSG_JAVA_SRC}") 
@@ -138,6 +178,11 @@ set(INCLUDE_PATH "-I${CMAKE_HOME_DIRECTORY}/src -I$ENV{SIMGRID_ROOT}/include -I$
 set(LIB_PATH "-L$ENV{SIMGRID_ROOT}/lib")
 SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${INCLUDE_PATH} ${LIB_PATH}")
 
+if(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
+    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wno-error=unused-but-set-variable ")
+endif(COMPILER_C_VERSION_MAJOR_MINOR MATCHES "4.6")
+
+
 ###########
 # TARGETS #
 ###########
@@ -170,12 +215,15 @@ add_custom_target(simgrid_jar ALL
 add_custom_command(
        COMMENT "Build examples for java"
        OUTPUT  ${JAVA_EXAMPLES_CLASS}
-       
+       DEPENDS ${JAVA_EXAMPLES}
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/basic/*.java  
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/pingPong/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/commTime/*.java
        COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/*.java                                 
+       COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/*.java
+       COMMAND ${JAVA_COMPILE} -d ${CMAKE_HOME_DIRECTORY}/examples -cp ${CMAKE_HOME_DIRECTORY}/simgrid.jar ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/*.java
 )
+
 add_custom_target(simgrid_java_examples ALL
        DEPENDS ${JAVA_EXAMPLES_CLASS}
 )
@@ -208,13 +256,36 @@ java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar
 ADD_TEST(mutualExclusion
 java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar mutualExclusion/centralized/MutexCentral ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/ring3.xml ${CMAKE_HOME_DIRECTORY}/examples/mutualExclusion/centralized/mutex_centralized_deployment.xml
 )
+ADD_TEST(bypass
+java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar master_slave_bypass/MsBypass ${CMAKE_HOME_DIRECTORY}/examples/master_slave_bypass/platform.xml
+)
+ADD_TEST(kill
+java -cp .:${CMAKE_HOME_DIRECTORY}/examples:${CMAKE_HOME_DIRECTORY}/simgrid.jar master_slave_kill/MsKill ${CMAKE_HOME_DIRECTORY}/examples/master_slave_kill/platform.xml
+)
+
+##########################################
+# Set the  DYLD_LIBRARY_PATH for mac     #
+##########################################
+if(APPLE)
+    if($ENV{DYLD_LIBRARY_PATH} STREQUAL "")
+        set_tests_properties(basic pingPong CommTime mutualExclusion bypass kill
+        PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:$ENV{SIMGRID_ROOT}/lib")
+    else($ENV{DYLD_LIBRARY_PATH} STREQUAL "")
+        set_tests_properties(basic pingPong CommTime mutualExclusion bypass kill
+        PROPERTIES ENVIRONMENT "DYLD_LIBRARY_PATH=$ENV{DYLD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:$ENV{SIMGRID_ROOT}/lib")
+    endif($ENV{DYLD_LIBRARY_PATH} STREQUAL "")
+endif(APPLE)
 
 ##########################################
 # Set the  LD_LIBRARY_PATH for our tests #
 ##########################################
-set_tests_properties(basic pingPong CommTime mutualExclusion
-PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:$ENV{LD_LIBRARY_PATH}")
-message(STATUS "export LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:$ENV{LD_LIBRARY_PATH}")
+if($ENV{LD_LIBRARY_PATH} STREQUAL "")
+    set_tests_properties(basic pingPong CommTime mutualExclusion bypass kill
+    PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=${CMAKE_HOME_DIRECTORY}/lib:$ENV{SIMGRID_ROOT}/lib")
+else($ENV{LD_LIBRARY_PATH} STREQUAL "")
+    set_tests_properties(basic pingPong CommTime mutualExclusion bypass kill
+    PROPERTIES ENVIRONMENT "LD_LIBRARY_PATH=$ENV{LD_LIBRARY_PATH}:${CMAKE_HOME_DIRECTORY}/lib:$ENV{SIMGRID_ROOT}/lib")
+endif($ENV{LD_LIBRARY_PATH} STREQUAL "")
 
 ###########
 # Install #
@@ -224,11 +295,60 @@ install(TARGETS SG_java
 install(FILES ${CMAKE_HOME_DIRECTORY}/simgrid.jar
        DESTINATION $ENV{DESTDIR}${CMAKE_INSTALL_PREFIX}/java/)
 
+
+#########
+# Dist  #
+#########
+
+add_custom_target(dist-dir
+  COMMENT "Generating the distribution directory"
+  COMMAND test -e ${DIST_NAME}/ && chmod -R a+w ${DIST_NAME}/ || true
+  COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
+  COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}
+)
+
+set(dirs_in_tarball "")
+foreach(file ${source_to_pack})
+
+  # This damn prefix is still set somewhere (seems to be in subdirs)
+  string(REPLACE "${CMAKE_HOME_DIRECTORY}/" "" file "${file}")
+  
+  # Create the directory on need
+  get_filename_component(file_location ${file} PATH)
+  string(REGEX MATCH ";${file_location};" OPERATION "${dirs_in_tarball}")
+  if(NOT OPERATION)
+       set(dirs_in_tarball "${dirs_in_tarball};${file_location};")
+       add_custom_command(
+         TARGET dist-dir
+         COMMAND ${CMAKE_COMMAND} -E make_directory ${DIST_NAME}/${file_location}/
+       )       
+   endif(NOT OPERATION)
+   
+   # Actually copy the file
+   add_custom_command(
+     TARGET dist-dir
+     COMMAND ${CMAKE_COMMAND} -E copy ${CMAKE_HOME_DIRECTORY}/${file} ${DIST_NAME}/${file_location}/
+   )
+endforeach(file ${source_to_pack})
+
+add_custom_target(dist
+  DEPENDS ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz
+  COMMENT "Generated ${DIST_NAME}"
+)
+add_custom_command(
+       OUTPUT ${CMAKE_BINARY_DIR}/${DIST_NAME}.tar.gz  
+       COMMENT "Compressing the archive from the distribution directory"
+       COMMAND ${CMAKE_COMMAND} -E tar cf ${DIST_NAME}.tar ${DIST_NAME}/
+       COMMAND gzip -9v ${DIST_NAME}.tar
+       COMMAND ${CMAKE_COMMAND} -E remove_directory ${DIST_NAME}/
+)
+add_dependencies(dist dist-dir)
+
 ########
 # NOTE #
 ########
 file(MAKE_DIRECTORY ${CMAKE_BINARY_DIR}/Testing/Notes/)
-file(WRITE ${CMAKE_BINARY_DIR}/Testing/Notes/Build  "SVN version : ${SVN_VERSION}\n")
-file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Release     : simgrid-java-${soversion}\n")
+file(WRITE ${CMAKE_BINARY_DIR}/Testing/Notes/Build  "GIT version : ${GIT_VERSION}\n")
+file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Release     : ${DIST_NAME}\n")
 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol user  : $ENV{PIPOL_USER}\n")
 file(APPEND ${CMAKE_BINARY_DIR}/Testing/Notes/Build "Pipol image : $ENV{PIPOL_IMAGE}\n")
\ No newline at end of file