Skip to content

Commit

Permalink
Cleanup after static build changes + update static_executable example.
Browse files Browse the repository at this point in the history
  • Loading branch information
timvdm committed Oct 21, 2010
1 parent 8ced975 commit 36128dc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 632 deletions.
200 changes: 4 additions & 196 deletions doc/examples/static_executable/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,6 @@
# plugin classes have to be undefined. Plugins can be disabled by removing
# the class names from the format_classes, descriptor_classes, ... lists below.
#
# Compilers:
# - GNU GCC: tested on linux
# - Intel ICC: not tested, should be the same as gcc
# - MSVC: not tested, uses different name mangling
# - MinGW: not tested, should be the same as gcc
#

# This line is required for cmake backwards compatibility.
cmake_minimum_required(VERSION 2.6)
Expand All @@ -40,178 +34,6 @@ set(sources myexe.cpp)
# Set the name for the executable
set(executable_target myexe)

#
# The plugin class names to include in the executable.
#
set(format_classes
ACRFormat
ADFOutputFormat
ADFInputFormat
OBT41Format
AlchemyFormat
AmberPrepFormat
OBAPIInterface
BallStickFormat
BGFFormat
BoxFormat
CacaoFormat
CacheFormat
CARFormat
CCCFormat
CHEM3D1Format
CHEM3D2Format
ChemDrawBinaryFormat
ChemDrawFormat
ChemKinFormat
CHTFormat
CIFFormat
CopyFormat
CRK2DFormat
CRK3DFormat
CSRFormat
CSSRFormat
DlpolyConfigFormat
DlpolyHISTORYFormat
DMolFormat
XXXFormat
FASTAFormat
FastSearchFormat
FCHKFormat
FEATFormat
FenskeZmatFormat
FHIainsFormat
FingerprintFormat
FreeFormFractionalFormat
GAMESSOutputFormat
GAMESSInputFormat
GAMESSUKFormat
GAMESSUKInputFormat
GAMESSUKOutputFormat
OBGaussianCubeFormat
GaussianOutputFormat
GaussianInputFormat
GaussianZMatrixInputFormat
GenBankFormat
GhemicalFormat
GROMOS96Format
GULPFormat
HINFormat
JaguarOutputFormat
JaguarInputFormat
MCDLFormat
MDLFormat
MOLFormat
SDFFormat
mmCIFFormat
MacroModFormat
MNAFormat
MOL2Format
OBMoldenFormat
MolproOutputFormat
MolproInputFormat
MolReportFormat
MOPACFormat
MOPACCARTFormat
MOPACINTFormat
MPDFormat
MPQCFormat
MPQCInputFormat
MSIFormat
OBMSMSFormat
NulFormat
NWChemOutputFormat
NWChemInputFormat
OBOpenDXCubeFormat
OutputFormat
PCModelFormat
PDBFormat
PDBQTFormat
PNGFormat
PovrayFormat
PQRFormat
PQSFormat
PWscfFormat
QChemOutputFormat
QChemInputFormat
ReportFormat
SmiReactFormat
RXNFormat
ShelXFormat
SMIFormat
CANSMIFormat
FIXFormat
SVGFormat
TextFormat
ThermoFormat
TinkerFormat
TitleFormat
TurbomoleFormat
UniChemFormat
VASPFormat
ViewMolFormat
XEDFormat
XTCFormat
XYZFormat
YOBFormat
ZINDOFormat
# XML formats
ChemDrawXMLFormat
CMLFormat
CMLReactFormat
PubChemFormat
XMLFormat
)

set(descriptor_classes
CanSmiles
CompoundFilter
MWFilter
SmartsFilter
TitleFilter
FormulaDescriptor
FPCount
InChIFilter
SmartsDescriptor
)

set(fingerprint_classes
fingerprint2
PatternFP
)

set(forcefield_classes
OBForceFieldGaff
OBForceFieldGhemical
OBForceFieldMMFF94
OBForceFieldUFF
)

set(op_classes
OpAddInIndex
OpAddPolarH
OpCanonical
OpConformer
OpFillUC
OpEnergy
OpMinimize
OpGen2D
OpGen3D
Op2D
OpNewS
OpPartialCharge
OpReadConformers
OpSort
OpUnique
OpExtraOut
)

set(charge_classes
GasteigerCharges
MMFF94Charges
QEqCharges
QTPIECharges
)

################################################################################

#
Expand All @@ -224,28 +46,11 @@ if(MSVC)
set(CMAKE_CXX_FLAGS_RELEASE "/MT /O2 /Ob2 /D NDEBUG")
set(CMAKE_EXE_LINKER_FLAGS_RELEASE "/INCREMENTAL:NO /NODEFAULTLIB:MSVCRT")
# Note: static libraries are specified when running cmake

#
# Perform name mangling for plugin symbols
#
# FIXME...
else()
# Use -static flag to create static executable
set(CMAKE_CXX_FLAGS "-static ${CMAKE_CXX_FLAGS}")
# Make sure we find static libraries
set(CMAKE_FIND_LIBRARY_SUFFIXES ".a")

#
# Perform name mangling for plugin symbols
#
foreach(plugin_classes ${format_classes} ${descriptor_classes} ${fingerprint_classes} ${forcefield_classes} ${op_classes} ${charge_classes})
foreach(plugin_class ${plugin_classes})
# Perform simple name mangling for symbol
string(LENGTH ${plugin_class} length)
set(plugin_symbols_link_flags "${plugin_symbols_link_flags} -u _ZTVN9OpenBabel${length}${plugin_class}E")
endforeach()
endforeach()
set(CMAKE_CXX_FLAGS "${plugin_symbols_link_flags} ${CMAKE_CXX_FLAGS}")
endif()

# Set the path containing OpenBabel2Config.cmake, needed for find_package below.
Expand All @@ -260,10 +65,13 @@ find_path(OpenBabel2_DIR OpenBabel2Config.cmake PATHS
find_package(OpenBabel2 REQUIRED)
include_directories(${OpenBabel2_INCLUDE_DIRS})

# Dependencies
find_package(LibXml2)

# The executable
add_executable(${executable_target} ${sources})
# Link against imported openbabel target
target_link_libraries(${executable_target} openbabel)
target_link_libraries(${executable_target} openbabel ${LIBXML2_LIBRARIES})
# Prevent -Wl,-Bdynamic from being added to the end of the link line.
set_target_properties(${executable_target} PROPERTIES
LINK_SEARCH_END_STATIC TRUE)
Expand Down
Loading

0 comments on commit 36128dc

Please sign in to comment.