set(HAVE_READLINE_HISTORY_H 1)
endif()
+find_package(LibDL)
+if (LIBDL_FOUND)
+ set(HAVE_LIBDL 1)
+endif()
+
find_program(MAKEINFO makeinfo)
find_program(FIG2DEV fig2dev)
set(${thename}_sources ${thename}.cpp ${${thename}_extra_src})
endif()
add_executable(${thename} EXCLUDE_FROM_ALL ${${thename}_sources})
- target_link_libraries(${thename} ginac)
+ target_link_libraries(${thename} ginac ${LIBDL_LIBRARIES})
add_dependencies(check ${thename})
add_test(NAME ${thename} COMMAND ${thename}${CMAKE_EXECUTABLE_SUFFIX})
endmacro()
--- /dev/null
+# - Find libdl
+# Find the native LIBDL includes and library
+#
+# LIBDL_INCLUDE_DIR - where to find dlfcn.h, etc.
+# LIBDL_LIBRARIES - List of libraries when using libdl.
+# LIBDL_FOUND - True if libdl found.
+
+
+IF (LIBDL_INCLUDE_DIR)
+ # Already in cache, be silent
+ SET(LIBDL_FIND_QUIETLY TRUE)
+ENDIF (LIBDL_INCLUDE_DIR)
+
+FIND_PATH(LIBDL_INCLUDE_DIR dlfcn.h)
+
+SET(LIBDL_NAMES dl libdl ltdl libltdl)
+FIND_LIBRARY(LIBDL_LIBRARY NAMES ${LIBDL_NAMES} )
+
+# handle the QUIETLY and REQUIRED arguments and set LIBDL_FOUND to TRUE if
+# all listed variables are TRUE
+INCLUDE(FindPackageHandleStandardArgs)
+FIND_PACKAGE_HANDLE_STANDARD_ARGS(LibDL DEFAULT_MSG LIBDL_LIBRARY LIBDL_INCLUDE_DIR)
+
+IF(LIBDL_FOUND)
+ SET( LIBDL_LIBRARIES ${LIBDL_LIBRARY} )
+ELSE(LIBDL_FOUND)
+ SET( LIBDL_LIBRARIES )
+ENDIF(LIBDL_FOUND)
+
+MARK_AS_ADVANCED( LIBDL_LIBRARY LIBDL_INCLUDE_DIR )
#cmakedefine HAVE_LIBREADLINE
#cmakedefine HAVE_READLINE_READLINE_H
#cmakedefine HAVE_READLINE_HISTORY_H
+#cmakedefine HAVE_LIBDL
// Our function pointer that points to the compiled ex
FUNCP_1P fp;
+
+ // Optionally, compile with custom compiler flags:
+ // setenv("CXXFLAGS", "-O3 -fomit-frame-pointer -ffast-math", 1);
compile_ex(expr, x, fp);
// Do some (not necessarily meaningful ;-)) numerical stuff ...
// Our function pointer that points to the compiled ex
FUNCP_CUBA fp;
+
+ // Optionally, compile with custom compiler flags:
+ // setenv("CXXFLAGS", "-O3 -fomit-frame-pointer -ffast-math", 1);
compile_ex(lst(expr), lst(x,y), fp);
// Starting VEGAS
cout << "Building new 'compile3_testprg.so'." << endl;
symbol a, b;
ex expr = a*b;
+
+ // Optionally, compile with custom compiler flags:
+ // setenv("CXXFLAGS", "-O3 -fomit-frame-pointer -ffast-math", 1);
compile_ex(expr, a, b, fp, "compile3_testprg");
}
@code{compile_ex} uses the shell script @code{ginac-excompiler} to start the C
compiler and produce the object files. This shell script comes with GiNaC and
will be installed together with GiNaC in the configured @code{$PREFIX/bin}
-directory.
+directory. You can also export additional compiler flags via the $CXXFLAGS
+variable:
+
+@example
+setenv("CXXFLAGS", "-O3 -fomit-frame-pointer -ffast-math", 1);
+compile_ex(...);
+@end example
@subsection Archiving
@cindex @code{archive} (class)
endif()
add_executable(ginsh ${ginsh_SOURCES} ${ginsh_HEADERS})
-target_link_libraries(ginsh ginac ${ginsh_extra_libs})
+target_link_libraries(ginsh ginac ${ginsh_extra_libs} ${LIBDL_LIBRARIES})
install(TARGETS ginsh RUNTIME DESTINATION "${BIN_INSTALL_DIR}")
add_definitions(-DIN_GINAC)
add_executable(viewgar viewgar.cpp)
-target_link_libraries(viewgar ginac)
+target_link_libraries(viewgar ginac ${LIBDL_LIBRARIES})
install(TARGETS viewgar RUNTIME DESTINATION "${BIN_INSTALL_DIR}")
+if (CMAKE_COMPILER_IS_GNUCC)
+ set (CC gcc)
+ configure_file (
+ "${CMAKE_CURRENT_SOURCE_DIR}/ginac-excompiler.in"
+ "${CMAKE_CURRENT_BINARY_DIR}/ginac-excompiler"
+ )
+
+ install(PROGRAMS ginac-excompiler DESTINATION "${BIN_INSTALL_DIR}")
+endif (CMAKE_COMPILER_IS_GNUCC)
#!/bin/sh
-@CC@ -x c -fPIC -shared -o $1.so $1
+@CC@ -x c -fPIC -shared $CXXFLAGS -o $1.so $1