Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Fix lua detection on apple and re-enable option lua and ruby. \But examples doesn...
authornavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 18 Nov 2010 16:43:39 +0000 (16:43 +0000)
committernavarrop <navarrop@48e7efb5-ca39-0410-a469-dd3cf9ba447f>
Thu, 18 Nov 2010 16:43:39 +0000 (16:43 +0000)
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@8575 48e7efb5-ca39-0410-a469-dd3cf9ba447f

buildtools/Cmake/CompleteInFiles.cmake
buildtools/Cmake/Distrib.cmake
buildtools/Cmake/MakeExeLib.cmake
buildtools/Cmake/Modules/FindLua51Simgrid.cmake [new file with mode: 0644]
buildtools/Cmake/Option.cmake
buildtools/Cmake/PrintArgs.cmake
examples/gras/console/CMakeLists.txt

index 7d9d66b..c6cc60e 100644 (file)
@@ -98,19 +98,11 @@ else(enable_model-checking AND HAVE_MMAP)
 endif(enable_model-checking AND HAVE_MMAP)
 
 if(enable_lua)
-       include(FindLua51)
+       include(FindLua51Simgrid)
        if(LUA51_FOUND)
                set(HAVE_LUA 1)
                SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-I${LUA_INCLUDE_DIR} ")
-               foreach(path_lua ${LUA_LIBRARIES})
-               string(REGEX REPLACE "liblua.*" "" path_lua_to_use ${path_lua})
-               string(REGEX MATCH ".*lua.*" operation "${path_lua}")
-               if(operation)
-                       string(REGEX REPLACE "${path_lua_to_use}" "" liblua ${path_lua})
-                       string(REPLACE "lib" "" liblua "${liblua}")
-                       string(REGEX REPLACE "[.][^.]*$" "" liblua "${liblua}")                 
-               endif(operation)
-               endforeach(path_lua ${LUA_LIBRARIES})
+               SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS}-L${LUA_LIBRARY_DIR} ")
        else(LUA51_FOUND)
                message("Lua binding need version 5.1 and cmake version 2.8")
                message("Cmake version ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION}")
index 53a4887..d8de077 100644 (file)
@@ -78,13 +78,13 @@ if(HAVE_LUA)
        file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/lua/5.1")
        add_custom_target(simgrid_lua ALL
                DEPENDS simgrid 
-                               ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
+                               ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.so
                )
        add_custom_command(
-               OUTPUT ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
-               COMMAND ${CMAKE_COMMAND} -E create_symlink ../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
+               OUTPUT ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.so
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.so
        )
-       install(FILES ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.${LIB_EXE}
+       install(FILES ${CMAKE_BINARY_DIR}/lib/lua/5.1/simgrid.so
                DESTINATION $ENV{DESTDIR}${prefix}/lib/lua/5.1
                )
 endif(HAVE_LUA)
@@ -94,13 +94,13 @@ if(HAVE_RUBY)
        file(MAKE_DIRECTORY "${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}")
        add_custom_target(ruby_simgrid ALL
                DEPENDS simgrid
-                               ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
+                               ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.so
        )
        add_custom_command(
-               OUTPUT ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
-               COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
+               OUTPUT ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.so
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ../../../libsimgrid.${LIB_EXE} ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.so
        )
-       install(FILES ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
+       install(FILES ${CMAKE_BINARY_DIR}/lib/ruby/${install_link_ruby}/libsimgrid.so
                DESTINATION $ENV{DESTDIR}${prefix}/lib/ruby/${install_link_ruby}/
        )
        install(FILES ${PROJECT_DIRECTORY}/src/bindings/ruby/simgrid.rb
@@ -151,7 +151,7 @@ endif(HAVE_JAVA)
 if(HAVE_LUA)
        add_custom_command(TARGET uninstall
        COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding lua ok"
-       COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/lua/5.1/simgrid.${LIB_EXE}  
+       COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/lua/5.1/simgrid.so
        WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
        )
 endif(HAVE_LUA)
@@ -160,7 +160,7 @@ if(HAVE_RUBY)
        string(REGEX REPLACE "^.*ruby/" "" install_link_ruby "${RUBY_ARCH_DIR}")
        add_custom_command(TARGET uninstall
        COMMAND ${CMAKE_COMMAND} -E echo "uninstall binding ruby ok"
-       COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/ruby/${install_link_ruby}/libsimgrid.${LIB_EXE}
+       COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/ruby/${install_link_ruby}/libsimgrid.so
        COMMAND ${CMAKE_COMMAND} -E remove -f ${prefix}/lib/ruby/${install_link_ruby}/simgrid.rb
        WORKING_DIRECTORY "${PROJECT_DIRECTORY}/"
        )
index 212e7fe..122efde 100644 (file)
@@ -33,12 +33,12 @@ endif(HAVE_PCRE_LIB)
 if(HAVE_RUBY)
        set(SIMGRID_DEP "${SIMGRID_DEP} -l${RUBY_LIBRARY_NAME} -module")
        ADD_CUSTOM_TARGET(link_simgrid_ruby ALL
-         DEPENDS simgrid ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
+         DEPENDS simgrid ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so
          )
        add_custom_command(
-               OUTPUT ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
-               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
-               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.${LIB_EXE}
+               OUTPUT ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so
+               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so # if it exists, creating the link fails. So cleanup before hand
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/src/bindings/ruby/libsimgrid.so
        )
 endif(HAVE_RUBY)
 
@@ -57,26 +57,26 @@ if(pthread)
 endif(pthread)
 
 if(HAVE_LUA)
-       SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${liblua}")   
+       SET(SIMGRID_DEP "${SIMGRID_DEP} -ldl -l${LIB_LUA_NAME}")   
          
     ADD_CUSTOM_TARGET(link_simgrid_lua ALL
       DEPENDS  simgrid
-                       ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE}
-                               ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE}
-                               ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE}
+                       ${PROJECT_DIRECTORY}/examples/lua/simgrid.so
+                               ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.so
+                               ${PROJECT_DIRECTORY}/examples/simdag/simgrid.so
        )
        add_custom_command(
-               OUTPUT  ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE}
-                               ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE}
-                               ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE}
-               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
-               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/lua/simgrid.${LIB_EXE} #for test
+               OUTPUT  ${PROJECT_DIRECTORY}/examples/lua/simgrid.so
+                               ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.so
+                               ${PROJECT_DIRECTORY}/examples/simdag/simgrid.so
+               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/lua/simgrid.so # if it exists, creating the link fails. So cleanup before hand
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/lua/simgrid.so #for test
                
-               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
-               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.${LIB_EXE} #for test
+               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.so # if it exists, creating the link fails. So cleanup before hand
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/msg/masterslave/simgrid.so #for test
                
-               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} # if it exists, creating the link fails. So cleanup before hand
-               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/simdag/simgrid.${LIB_EXE} #for test                      
+               COMMAND ${CMAKE_COMMAND} -E remove -f ${PROJECT_DIRECTORY}/examples/simdag/simgrid.so # if it exists, creating the link fails. So cleanup before hand
+               COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${PROJECT_DIRECTORY}/examples/simdag/simgrid.so #for test                      
        )
 endif(HAVE_LUA)
 
diff --git a/buildtools/Cmake/Modules/FindLua51Simgrid.cmake b/buildtools/Cmake/Modules/FindLua51Simgrid.cmake
new file mode 100644 (file)
index 0000000..38ec42c
--- /dev/null
@@ -0,0 +1,34 @@
+find_path(HAVE_LUA_H lua.h
+    HINTS
+    $ENV{LD_LIBRARY_PATH}
+    PATH_SUFFIXES lua/ lua/5.1/ include
+    PATHS
+    /opt
+    /opt/local
+    /opt/csw
+    /sw
+    /usr
+)
+
+find_library(HAVE_LUA51_LIB
+    NAME lua.5.1 lua5.1
+    HINTS
+    $ENV{LD_LIBRARY_PATH}
+    PATHS
+    /opt
+    /opt/local
+    /opt/csw
+    /sw
+    /usr
+)
+
+set(LIB_LUA_NAME ${HAVE_LUA51_LIB})
+string(REGEX MATCH "liblua.*$" LIB_LUA_NAME "${LIB_LUA_NAME}")
+string(REPLACE ".${LIB_EXE}" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
+string(REPLACE "lib" "" LIB_LUA_NAME "${LIB_LUA_NAME}")
+
+if(HAVE_LUA_H AND HAVE_LUA51_LIB AND LIB_LUA_NAME)
+ set(LUA51_FOUND 1)
+ string(REPLACE "/lua.h" "" LUA_INCLUDE_DIR ${HAVE_LUA_H})
+ string(REPLACE "/lib${LIB_LUA_NAME}.${LIB_EXE}" "" LUA_LIBRARY_DIR ${HAVE_LUA51_LIB})
+endif(HAVE_LUA_H AND HAVE_LUA51_LIB AND LIB_LUA_NAME)
\ No newline at end of file
index 6d20477..8d8a4af 100644 (file)
@@ -29,8 +29,13 @@ else(CMAKE_SYSTEM_NAME MATCHES "Darwin")
 endif(CMAKE_SYSTEM_NAME MATCHES "Darwin")
 option(enable_gtnets "Whether gtnets model is activated." on)
 option(enable_java "Whether the Java bindings are activated." on)
+if(WIN32 OR APPLE) 
+option(enable_lua "Whether the lua bindings are activated." off)
+option(enable_ruby "Whether the Ruby bindings are activated." off)
+else(WIN32 OR APPLE)
 option(enable_lua "Whether the lua bindings are activated." on)
 option(enable_ruby "Whether the Ruby bindings are activated." on)
+endif(WIN32 OR APPLE) 
 option(enable_doc "Whether we should rebuild the documentation" off)
 option(enable_compile_optimizations "" off)
 option(enable_compile_warnings "Whether compilation warnings should be turned into errors." off)
@@ -47,25 +52,19 @@ option(enable_graphviz "" off)
 
 if(WIN32 OR APPLE) #actually not enable with windows and Apple
        message("-- Mode supernovae and maintainer are disabled.")
-    message("-- Model checking is disabled.")
-       message("-- Smpi, Ruby, Lua and GTnets are disabled.")
+       message("-- Smpi and GTnets are disabled.")
        set(enable_supernovae false CACHE TYPE INTERNAL FORCE)
        set(enable_maintainer_mode false CACHE TYPE INTERNAL FORCE)
-       set(enable_lua false CACHE TYPE INTERNAL FORCE)
-       set(enable_ruby false CACHE TYPE INTERNAL FORCE)
        set(enable_smpi false CACHE TYPE INTERNAL FORCE)
        set(enable_gtnets false CACHE TYPE INTERNAL FORCE) 
-       set(enable_model-checking false CACHE TYPE INTERNAL FORCE)
        mark_as_advanced(enable_supernovae)
     mark_as_advanced(enable_maintainer_mode)
-    mark_as_advanced(enable_lua)
-    mark_as_advanced(enable_ruby)
     mark_as_advanced(enable_smpi)
     mark_as_advanced(enable_gtnets)
     mark_as_advanced(gtnets_path)
-    mark_as_advanced(enable_model-checking)
 endif(WIN32 OR APPLE)
 
+
 if(enable_supernovae AND enable_model-checking)
        set(enable_model-checking false CACHE TYPE INTERNAL FORCE)
        message("\n\nWith supernovae mode the model checking must be disable.!!!\n\n")
@@ -83,6 +82,8 @@ mark_as_advanced(LUA_LIB_PATH_2)
 mark_as_advanced(LUA_LIB_PATH_3)
 mark_as_advanced(HAVE_LUA5_1_LAUXLIB_H)                        
 mark_as_advanced(HAVE_LUA5_1_LUALIB_H)
+mark_as_advanced(HAVE_LUA51_LIB)                                                                                                                                                                             
+mark_as_advanced(HAVE_LUA_H)
 mark_as_advanced(RUBY_LIB_PATH_1)                                                                                                                      
 mark_as_advanced(RUBY_LIB_PATH_2)
 mark_as_advanced(CLEAR gtnets_path)
index 8e7b7f0..e9d5f67 100644 (file)
@@ -103,8 +103,12 @@ if(enable_print_message)
        endif(enable_java)
        if(enable_lua)
        message("")
-       message("LUA_INCLUDE_DIR :              ${LUA_INCLUDE_DIR}")
-       message("LIBLUA :                       ${liblua}")
+    message("HAVE_LUA_H = ${HAVE_LUA_H}")
+    message("HAVE_LUA51_LIB = ${HAVE_LUA51_LIB}")
+    message("LUA_INCLUDE_DIR = ${LUA_INCLUDE_DIR}")
+    message("LIB_LUA_NAME = ${LIB_LUA_NAME}")
+    message("LUA_LIBRARY_DIR = ${LUA_LIBRARY_DIR}")
+    
        endif(enable_lua)
        if(enable_memcheck)
        message("")
@@ -176,9 +180,9 @@ message("   Compile Gtnets :        ${HAVE_GTNETS}")
 message("      Gtnets path    :        ${gtnets_path}")
 endif(NOT APPLE AND NOT WIN32)
 message("      Compile Java   :        ${HAVE_JAVA}")
-if(NOT APPLE AND NOT WIN32)
 message("      Compile Lua    :        ${HAVE_LUA}")
 message("      Compile Ruby   :        ${HAVE_RUBY}")
+if(NOT APPLE AND NOT WIN32)
 message("      Compile Smpi   :        ${enable_smpi}")
 endif(NOT APPLE AND NOT WIN32)
 message("      Compile Static :        ${enable_lib_static}")
@@ -186,8 +190,8 @@ message("")
 if(NOT APPLE AND NOT WIN32)
 message("      Maintainer mode:        ${enable_maintainer_mode}")
 message("      Supernovae mode:        ${enable_supernovae}")
-message("      Model checking :        ${enable_model-checking}")
 endif(NOT APPLE AND NOT WIN32)
+message("      Model checking :        ${enable_model-checking}")
 message("      Tracing mode   :        ${enable_tracing}")
 message("      Latency bound  :        ${enable_latency_bound_tracking}")
 message("        Graphviz mode  :        ${enable_graphviz}")
index 65c8f53..f943e99 100644 (file)
@@ -25,13 +25,11 @@ add_custom_command(
                                        OUTPUT  ${CMAKE_CURRENT_SOURCE_DIR}/_ping_simulator.c 
                                                ${CMAKE_CURRENT_SOURCE_DIR}/_ping_client.c 
                                                        ${CMAKE_CURRENT_SOURCE_DIR}/_ping_server.c
-                                                       ${CMAKE_HOME_DIRECTORY}/examples/gras/console/simgrid.${LIB_EXE}
-                                       COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_HOME_DIRECTORY}/examples/gras/console/simgrid.${LIB_EXE}
+                                                       ${CMAKE_HOME_DIRECTORY}/examples/gras/console/simgrid.so
+                                       COMMAND ${CMAKE_COMMAND} -E create_symlink ${CMAKE_BINARY_DIR}/lib/libsimgrid.${LIB_EXE} ${CMAKE_HOME_DIRECTORY}/examples/gras/console/simgrid.so
                                        COMMAND lua ${CMAKE_CURRENT_SOURCE_DIR}/ping_generator.lua
                                        WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} #needed to find simgrid.so. By default CMAKE_CURRENT_BINARY_DIR
                                        )
-                                       
-
 
 ### Add definitions for compile
 target_link_libraries(ping_simulator_console simgrid pthread m )