Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Do not load internal headers when compiling the examples
authorMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Mar 2018 19:43:21 +0000 (20:43 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Mon, 19 Mar 2018 20:40:11 +0000 (21:40 +0100)
CMakeLists.txt
include/xbt/mmalloc.h
teshsuite/mc/CMakeLists.txt
teshsuite/simdag/CMakeLists.txt
teshsuite/surf/CMakeLists.txt
teshsuite/xbt/CMakeLists.txt
tools/cmake/Java.cmake
tools/cmake/MakeLib.cmake
tools/cmake/Tests.cmake
tools/cmake/UnitTesting.cmake

index 41f6c7a..62c423e 100644 (file)
@@ -159,20 +159,26 @@ endif()
 SET(LIBRARY_OUTPUT_PATH ${CMAKE_BINARY_DIR}/lib)
 
 ### Compute the include paths
-set(INCLUDES
+
+# Only include public headers by default
+include_directories(
+   ${CMAKE_BINARY_DIR}/include
+   ${CMAKE_HOME_DIRECTORY}/include
+)
+
+# Compute the ones that should be added when compiling the library
+set(INTERNAL_INCLUDES
   ${CMAKE_BINARY_DIR}
-  ${CMAKE_BINARY_DIR}/include
   ${CMAKE_HOME_DIRECTORY}
-  ${CMAKE_HOME_DIRECTORY}/include
   ${CMAKE_HOME_DIRECTORY}/src/include
   )
 
 if(enable_smpi)
-  set (INCLUDES ${INCLUDES} ${CMAKE_HOME_DIRECTORY}/src/smpi/include)
+  set (INTERNAL_INCLUDES ${INTERNAL_INCLUDES} ${CMAKE_HOME_DIRECTORY}/src/smpi/include)
 endif()
 
 if(NOT CMAKE_CROSSCOMPILING AND EXISTS /usr/include/)
-  set(INCLUDES ${INCLUDES} /usr/include/)
+  set(INTERNAL_INCLUDES ${INTERNAL_INCLUDES} /usr/include/)
 endif()
 
 if(WIN32)
@@ -180,12 +186,10 @@ if(WIN32)
   set(CMAKE_LIB_WIN "${CMAKE_C_COMPILER}")
   string(REGEX REPLACE "/bin/gcc.*" "/include"  CMAKE_INCLUDE_WIN "${CMAKE_INCLUDE_WIN}")
   string(REGEX REPLACE "/bin/gcc.*" "/lib"  CMAKE_LIB_WIN "${CMAKE_LIB_WIN}")
-  set(INCLUDES ${INCLUDES} ${CMAKE_INCLUDE_WIN})
+  set(INTERNAL_INCLUDES ${INTERNAL_INCLUDES} ${CMAKE_INCLUDE_WIN})
   unset(CMAKE_INCLUDE_WIN)
 endif()
 
-include_directories(${INCLUDES})
-
 # library dependency cannot start with a space (CMP0004), so initialize it with something that is never desactivated.
 set(SIMGRID_DEP "-lm") 
 
index eff59a0..62d0a00 100644 (file)
@@ -1,5 +1,4 @@
-/* Copyright (c) 2010-2018. The SimGrid Team.
- * All rights reserved.                                                     */
+/* Copyright (c) 2010-2018. The SimGrid Team. All rights reserved.          */
 
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
index 5d42234..e1618b9 100644 (file)
@@ -3,6 +3,7 @@ foreach(x dwarf dwarf-expression)
     add_executable       (${x}  ${x}/${x}.cpp)
     target_link_libraries(${x}  simgrid)
     set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+    set_property(TARGET ${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
   endif()
 
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
index f059384..b0d6575 100644 (file)
@@ -21,6 +21,7 @@ foreach(x flatifier is-router)
   add_executable       (${x}  ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+  set_property(TARGET ${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
index 8bede3c..467abf9 100644 (file)
@@ -2,6 +2,7 @@ foreach(x lmm_usage surf_usage surf_usage2)
   add_executable       (${x}  ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+  set_property(TARGET ${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
@@ -10,6 +11,7 @@ endforeach()
 add_executable       (maxmin_bench maxmin_bench/maxmin_bench.cpp)
 target_link_libraries(maxmin_bench simgrid)
 set_target_properties(maxmin_bench PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/maxmin_bench)
+set_property(TARGET maxmin_bench APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
 foreach(x small medium large)
   set(tesh_files     ${tesh_files}     ${CMAKE_CURRENT_SOURCE_DIR}/maxmin_bench/maxmin_bench_${x}.tesh)
index 8a16af4..bd505c8 100644 (file)
@@ -11,6 +11,7 @@ foreach(x parmap_bench parmap_test)
   add_executable       (${x}  ${x}/${x}.cpp)
   target_link_libraries(${x}  simgrid)
   set_target_properties(${x}  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${x})
+  set_property(TARGET ${x} APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
   set(tesh_files    ${tesh_files}    ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.tesh)
   set(teshsuite_src ${teshsuite_src} ${CMAKE_CURRENT_SOURCE_DIR}/${x}/${x}.cpp)
@@ -19,7 +20,8 @@ endforeach()
 if(HAVE_MMALLOC)
   add_executable       (mmalloc_test ${CMAKE_CURRENT_SOURCE_DIR}/mmalloc/mmalloc_test.cpp)
   target_link_libraries(mmalloc_test simgrid)
-  set_target_properties(mmalloc_test  PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mmalloc)
+  set_target_properties(mmalloc_test PROPERTIES RUNTIME_OUTPUT_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/mmalloc)
+  set_property(TARGET mmalloc_test APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 endif()
 
 set(tesh_files    ${tesh_files}     ${CMAKE_CURRENT_SOURCE_DIR}/log_usage/log_usage_ndebug.tesh
index 24c0994..fecf92b 100644 (file)
@@ -28,6 +28,8 @@ endif()
 add_library(simgrid-java SHARED ${JMSG_C_SRC})
 set_target_properties(simgrid-java PROPERTIES VERSION          ${libsimgrid-java_version})
 set_target_properties(simgrid-java PROPERTIES SKIP_BUILD_RPATH ON)
+set_property(TARGET simgrid-java
+             APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
 target_link_libraries(simgrid-java simgrid)
 
index 3f634dd..66886a7 100644 (file)
@@ -20,6 +20,9 @@ endif()
 # Actually declare our libraries
 add_library(simgrid SHARED ${simgrid_sources})
 set_target_properties(simgrid PROPERTIES VERSION ${libsimgrid_version})
+# The library can obviously use the internal headers
+set_property(TARGET simgrid
+             APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
 
 add_dependencies(simgrid maintainer_files)
 
@@ -27,10 +30,13 @@ if(enable_model-checking)
   add_executable(simgrid-mc ${MC_SIMGRID_MC_SRC})
   target_link_libraries(simgrid-mc simgrid)
   set_target_properties(simgrid-mc
-    PROPERTIES
-      RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+                        PROPERTIES RUNTIME_OUTPUT_DIRECTORY "${CMAKE_BINARY_DIR}/bin")
+  set_property(TARGET simgrid-mc
+               APPEND PROPERTY INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}")
+
 endif()
 
+
 # Compute the dependencies of SimGrid
 #####################################
 if (HAVE_BOOST_CONTEXTS)
index 39e78d8..b1c99ef 100644 (file)
@@ -93,6 +93,12 @@ if(Boost_UNIT_TEST_FRAMEWORK_FOUND)
   add_executable       (unit_tmgr src/surf/trace_mgr_test.cpp)
   target_link_libraries(unit_tmgr simgrid ${Boost_UNIT_TEST_FRAMEWORK_LIBRARY})
   ADD_TEST(unit_tmgr ${CMAKE_BINARY_DIR}/unit_tmgr --build_info=yes)
+  set_property(
+    TARGET unit_tmgr
+    APPEND PROPERTY
+           INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}"
+          )  
+  
   
 else()
   set(EXTRA_DIST       ${EXTRA_DIST}       src/surf/trace_mgr_test.cpp)
index 43af655..cd3f9a4 100644 (file)
@@ -46,4 +46,9 @@ ADD_CUSTOM_COMMAND(
 
 add_executable       (testall ${EXTRACTED_TEST_SOURCE_FILES})
 target_link_libraries(testall simgrid)
+set_property(
+    TARGET testall
+    APPEND PROPERTY
+           INCLUDE_DIRECTORIES "${INTERNAL_INCLUDES}"
+          )