3 # Copyright (c) 2014-2023. The SimGrid Team.
6 # This program is free software; you can redistribute it and/or modify it
7 # under the terms of the license (GNU LGPL) which comes with this package.
9 SIMGRID_VERSION="@SIMGRID_VERSION_STRING@"
10 SIMGRID_GITHASH="@GIT_VERSION@"
12 CXX=@CMAKE_CXX_COMPILER@
16 list_set INCLUDEARGS @includeflag@
17 list_set CMAKE_LINKARGS "-L@libdir@"
19 list_set CXXFLAGS "-std=gnu++11" @SMPI_CXX_FLAGS@
22 if [ "@CMAKE_C_COMPILER_ID@" = "Clang" ] && [ "@HAVE_SANITIZER_ADDRESS@" = "TRUE" ]; then
23 LINKER_UNDEFINED_ERROR=""
25 LINKER_UNDEFINED_ERROR="1"
28 if [ "x@APPLE@" = "x1" ]; then
29 if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
30 list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
31 list_add LINKARGS "-shared"
33 echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
35 if [ "x${SMPI_NO_UNDEFINED_CHECK}" = "x" ]; then
36 list_add LINKARGS "-lsimgrid" "-lm" ${LINKER_UNDEFINED_ERROR:+"-Wl,-undefined,error"}
39 if [ "x${SMPI_PRETEND_CC}" = "x" ]; then
40 list_add CXXFLAGS "-include" "@includedir@/smpi/smpi_helpers.h"
41 list_add LINKARGS "-shared"
43 echo "Warning: smpicc pretends to be a regular compiler (SMPI_PRETEND_CC is set). Produced binaries will not be usable in SimGrid."
45 if [ "x${SMPI_NO_UNDEFINED_CHECK}" = "x" ]; then
46 list_add LINKARGS "-lsimgrid" "-lm" ${LINKER_UNDEFINED_ERROR:+"-Wl,-z,defs"}
51 while [ $# -gt 0 ]; do
61 SRCFILE="$(readlink -f "${ARG}" 2>/dev/null)"
62 if [ -z "$SRCFILE" ] ; then
65 list_add CMDARGS "${SRCFILE}"
67 '-version' | '--version')
68 printf '%b\n' "$SIMGRID_VERSION"
71 "-git-version" | "--git-version")
72 printf '%b\n' "$SIMGRID_GITHASH"
75 '-compiler-version' | '--compiler-version')
78 '-show'|'-compile-info'|'-link-info')
79 # Dry run displaying commands instead of executing them. Useful to cmake
83 list_add CMDARGS "${ARG}"
88 list_add CMDARGS "-fPIC"
90 list_set CMDLINE "${CXX}"
91 list_add_not_empty CMDLINE "${CXXFLAGS}"
92 list_add_not_empty CMDLINE "${INCLUDEARGS}"
93 list_add_not_empty CMDLINE "${CMAKE_LINKARGS}"
94 list_add_not_empty CMDLINE "${CMDARGS}"
95 list_add_not_empty CMDLINE "${LINKARGS}"
97 eval $(list_get CMDLINE)
98 if [ "x$VERBOSE" = x1 ] || [ "x$show" = x1 ] ; then
100 [ "x$show" = x1 ] && exit 0