Commit 086f4be1 authored by Berk Onat's avatar Berk Onat
Browse files

Combining CMake files

parent c6feda88
cmake_minimum_required(VERSION 2.8.12)
if(NOT DEFINED CMAKE_MACOSX_RPATH)
set(CMAKE_MACOSX_RPATH 0)
endif()
project(molfile)
# Set source directory
set(SOURCE_DIR "molfile")
add_subdirectory(external)
add_subdirectory(molfile_plugins)
# Tell CMake that headers are also in SOURCE_DIR
include_directories(${SOURCE_DIR} "${SOURCE_DIR}/vmd_molfile_plugin/molfile_plugin/include" "${SOURCE_DIR}/vmd_molfile_plugin/molfile_plugin/lib")
set_source_files_properties( external/tng/include/tng/tng_io.h PROPERTIES GENERATED TRUE )
set(SOURCES "${SOURCE_DIR}/libpymolfile_wrap.cxx" "${SOURCE_DIR}/pymolfile.c" "${SOURCE_DIR}/lib/libmolfile_plugin.a")
add_dependencies( molfile_plugins_comp tngio_comp )
......@@ -2,8 +2,8 @@ cmake_minimum_required(VERSION 2.8.12)
project(TNGBuilder)
include(ExternalProject)
set(TNG_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/tng")
set(TNG_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/tng")
set(TNG_PREFIX "${CMAKE_CURRENT_BINARY_DIR}/external/tng")
set(TNG_INSTALL_DIR "${CMAKE_CURRENT_BINARY_DIR}/external/tng")
set(TNG_CMAKE_ARGS -DCMAKE_INSTALL_PREFIX=${TNG_INSTALL_DIR})
message("TNG_PREFIX='${TNG_PREFIX}'")
......@@ -17,3 +17,18 @@ ExternalProject_Add(tng
INSTALL_DIR ${TNG_INSTALL_DIR}
CMAKE_ARGS ${TNG_CMAKE_ARGS}
)
set(LIB_TNGIO_FILES
"${TNG_INSTALL_DIR}/tng/include/tng/tng_io.h")
if (APPLE)
set(LIB_TNGIO_FILES ${LIB_TNGIO_FILES} "${TNG_INSTALL_DIR}/tng/lib/libtng_io.dylib")
else()
set(LIB_TNGIO_FILES ${LIB_TNGIO_FILES} "${TNG_INSTALL_DIR}/tng/lib/libtng_io.so")
endif()
add_custom_target(tngio_comp ALL
DEPENDS ${LIB_TNGIO_FILES}
)
cmake_minimum_required(VERSION 2.8.12)
#find_package (EXPAT)
#find_package (NetCDF)
project(myexecutable)
# Set source directory
#set(SOURCE_DIR "molfile")
# Tell CMake that headers are also in SOURCE_DIR
#include_directories(${SOURCE_DIR} "${SOURCE_DIR}/vmd_molfile_plugin/molfile_plugin/include" "${SOURCE_DIR}/vmd_molfile_plugin/molfile_plugin/lib")
project(molfileplugins)
#set(SOURCES "${SOURCE_DIR}/libpymolfile_wrap.cxx" "${SOURCE_DIR}/pymolfile.c" "${SOURCE_DIR}/lib/libmolfile_plugin.a")
find_package(EXPAT)
find_package(NetCDF)
find_package(TCL)
if (EXISTS "${TNG_INSTALL_DIR}/tng/lib/libtng_io.dylib"
OR EXISTS "${TNG_INSTALL_DIR}/tng/lib/libtng_io.so"
OR EXISTS "${TNG_INSTALL_DIR}/tng/include/tng/tng_io.h")
set(TNGIO_FOUND TRUE)
set(TNGIO_LIBRARIES "${TNG_INSTALL_DIR}/lib/")
set(TNGIO_INLCUDE_DIRS "${TNG_INSTALL_DIR}/include/")
endif()
set(TARGET_ARCH_REGEX "^.*-march[= ]([^ ]+).*$")
string(REGEX MATCH "${TARGET_ARCH_REGEX}" TARGET_ARCH_MATCH "${CMAKE_C_FLAGS}" "${CMAKE_CXX_FLAGS}")
if (TARGET_ARCH_MATCH)
string(REGEX REPLACE "${TARGET_ARCH_REGEX}" "\\1" TARGET_ARCH "${CMAKE_C_FLAGS}" "${CMAKE_CXX_FLAGS}")
string(REGEX REPLACE "${TARGET_ARCH_REGEX}" "\\1" TARGET_ARCH "${CMAKE_C_FLAGS}" "${CMAKE_CXX_FLAGS}")
else()
set(TARGET_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
set(TARGET_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()
message(TARGET_ARCH= ${TARGET_ARCH})
message(OSX= ${OSX_ARCHITECTURES})
message(OSX= ${CMAKE_OSX_ARCHITECTURES})
message(SYS_VER= ${CMAKE_SYSTEM_VERSION})
message(SYS_NAME= ${CMAKE_SYSTEM_NAME})
message(SYS_PROC= ${CMAKE_SYSTEM_PROCESSOR})
message(SYS= ${CMAKE_SYSTEM})
message(TARGET_ARCH_REGEX= ${TARGET_ARCH_REGEX})
message(TARGET_ARCH_MATCH= ${TARGET_ARCH_MATCH})
add_custom_command(
OUTPUT vmd_molfile_plugins/compile/lib_MACOSXX86_64GCC/molfile/libmolfile_plugins.a
COMMAND make MACOSXX86_64GCCTNG
WORKING_DIRECTORY vmd_molfile_plugins
)
add_custom_target(
libmolfile_plugins.a
COMMAND make MACOSXX86_64GCCTNG
WORKING_DIRECTORY vmd_molfile_plugins
if(TARGET_ARCH MATCHES "^.*64.*$")
set(ARCH64BIT TRUE)
endif()
set(LIB_MOLFILE_FILES
"${CMAKE_CURRENT_BINARY_DIR}/molfile_plugins/compile/lib/libmolfile_plugins.a"
"${CMAKE_CURRENT_BINARY_DIR}/molfile_plugins/compile/lib/libmolfile_plugins.h")
if(UNIX AND NOT APPLE)
set(LINUX TRUE)
endif()
if(WIN32)
if(MSVS OR MSYS)
set(WINCOMP TRUE)
endif()
endif()
if(LINUX)
if(CMAKE_CXX_COMPILER_ID MATCHES "^.*GNU.*$")
if(ARCH64BIT)
set(TARGET_COPT " -fPIC -m64 -o ")
set(TARGET_LOPT " -fPIC -m64 -lstdc++ -o ")
set(TARGET_CFLAGS " -m64 -O2 -fPIC -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -m64 -O2 -fPIC -Wall ${CMAKE_CXX_FLAGS}")
else()
set(TARGET_COPT " -fPIC -m32 -o ")
set(TARGET_LOPT " -fPIC -m32 -lstdc++ -o ")
set(TARGET_CFLAGS " -m32 -O2 -fPIC -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -m32 -O2 -fPIC -Wall ${CMAKE_CXX_FLAGS}")
endif()
else()
set(TARGET_COPT " -o ")
set(TARGET_LOPT " -o ")
set(TARGET_CFLAGS " -O2 -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -O2 -Wall ${CMAKE_CXX_FLAGS}")
endif()
endif()
if(APPLE)
if(CMAKE_CXX_COMPILER_ID MATCHES "^.*GNU.*$"
OR CMAKE_CXX_COMPILER_ID MATCHES "^(Apple)?Clang$")
if(ARCH64BIT)
set(TARGET_COPT -m64;-fPIC;-o)
set(TARGET_LOPT -m64;-fPIC;-o)
set(TARGET_CFLAGS -m64;-Os;-Wall;-fPIC;-dynamic;${CMAKE_C_FLAGS})
set(TARGET_CXXFLG -m64;-Os;-Wall;-fPIC;-dynamic;${CMAKE_CXX_FLAGS})
else()
set(TARGET_COPT " -fPIC -m32 -o ")
set(TARGET_LOPT " -fPIC -m32 -o ")
set(TARGET_CFLAGS " -m32 -Os -Wall -fPIC -dynamic ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -m32 -Os -Wall -fPIC -dynamic ${CMAKE_CXX_FLAGS}")
endif()
else()
set(TARGET_COPT " -o ")
set(TARGET_LOPT " -o ")
set(TARGET_CFLAGS " -O2 -Wall ${CMAKE_C_FLAGS}")
set(TARGET_CXXFLG " -O2 -Wall ${CMAKE_CXX_FLAGS}")
endif()
endif()
if(UNIX)
set(TARGET_DEF "-D")
set(TARGET_SHLD ${CMAKE_CXX_COMPILER} ${CMAKE_SHARED_LIBRARY_CREATE_CXX_FLAGS})
set(TARGET_LIBTOOL libtool;-dynamic)
set(TARGET_AR ${CMAKE_AR})
set(TARGET_NM ${CMAKE_NM};-p)
set(TARGET_RANLIB ${CMAKE_RANLIB})
set(TARGET_MOL_LIBS "")
if(TCL_FOUND)
set(TCLLDFLAGS -ltcl;-L${TCL_LIBRARY})
set(TCLINC "-I${TCL_INCLUDE_PATH}")
set(TCLLIB "-L${TCL_LIBRARY}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"TCLLDFLAGS=${TCLLDFLAGS}\";\"TCLINC=${TCLINC}\";\"TCLLIB=${TCLLIB}\";)
endif()
if(EXPAT_FOUND)
set(EXPATLDFLAGS ${EXPAT_LIBRARIES})
set(EXPATINC "-I${EXPAT_INCLUDE_DIRS}")
set(EXPATLIB "-I${EXPAT_INCLUDE_DIRS}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"EXPATLDFLAGS=${EXPATLDFLAGS}\";\"EXPATINC=${EXPATINC}\";\"EXPATLIB=${EXPATLIB}\";)
endif()
if(NETCDF_FOUND)
set(NETCDFLDFLAGS ${NETCDF_LIBRARY})
set(NETCDFINC "-I${NETCDF_INCLUDE_DIRS}")
set(NETCDFLIB "-I${NETCDF_INCLUDE_DIRS}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"NETCDFLDFLAGS=${NETCDFLDFLAGS}\";\"NETCDFINC=${NETCDFINC}\";\"NETCDFLIB=${NETCDFLIB}\";)
endif()
if(TNGIO_FOUND)
set(TNGIOLDFLAGS -ltng_io)
set(TNGIOINC "-I${TNGIO_INCLUDE_DIRS}")
set(TNGIOLIB "-L${TNGIO_LIBRARIES}")
set(TARGET_MOL_LIBS ${TARGET_MOL_LIBS} \"TNGLDFLAGS=${TNGIOLDFLAGS}\";\"TNGINC=${TNGIOINC}\";\"TNGLIB=${TNGIOLIB}\";)
endif()
add_custom_command(
OUTPUT ${LIB_MOLFILE_FILES}
COMMAND make dynlibs staticlibs bins \"ARCH = ${TARGET_ARCH}\" \"COPTO = ${TARGET_COPT} \" \"LOPTO = ${TARGET_LOPT} \" \"CC = ${CMAKE_C_COMPILER} \" \"CXX = ${CMAKE_CXX_COMPILER} \" \"DEF = ${TARGET_DEF}\" \"CCFLAGS = ${TARGET_CFLAGS} \" \"CXXFLAGS = ${TARGET_CXXFLG} \" \"AR = ${TARGET_AR}\" \"NM = ${TARGET_NM}\" \"RANLIB = ${TARGET_RANLIB}\" \"LIBTOOL = ${TARGET_LIBTOOL} \" ${TARGET_MOL_LIBS}
COMMENT "Compiling libmolfile_plugin.a"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/molfile_plugins/molfile_plugin"
)
endif()
if(WINCOMP)
set(TARGET_DEF "/D")
set(TARGET_AR "${CMAKE_AR}")
set(TARGET_NM "${CMAKE_NM} -p")
set(TARGET_RANLIB "${CMAKE_RANLIB}")
set(TARGET_MOL_LIBS "")
set(TARGET_SHLDFLAGS "/D\"VMDPLUGIN_EXPORTS\"")
if(MSVS)
set(MYMAKE nmake)
else()
set(MYMAKE make)
endif()
if(ARCH64BIT)
set(TARGET_SHLD "\"link /DLL /nologo /incremental:no kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib wsock32.lib /MACHINE:X64 /OPT:REF\"")
set(TARGET_MOL_SETTINGS "\"CC = cl.exe /nologo /MT /DWIN64\"" "\"CXX = cl.exe /nologo /MT /TP /DWIN64\"" "\"CCFLAGS = /EHsc /Wp64 /wd4996 /O2 /D\\\"_CRT_SECURE_NO_DEPRECATE\\\"\"" "\"CXXFLAGS = /EHsc /Wp64 /wd4996 /O2 /D\\\"_CRT_SECURE_NO_DEPRECATE\\\"\"")
else()
set(TARGET_SHLD "\"link /DLL /nologo /incremental:no kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ws2_32.lib wsock32.lib /OPT:REF\"")
set(TARGET_MOL_SETTINGS "\"CC = cl.exe /nologo /MT /DWIN32\"" "\"CXX = cl.exe /nologo /MT /TP /DWIN32\"" "\"CCFLAGS = /O2 /G5\"" "\"CXXFLAGS = /O2 /G5\"")
endif()
add_custom_command(
OUTPUT ${LIB_MOLFILE_FILES}
COMMAND ${MYMAKE} dynlibs win32staticlibs "\" ARCH = ${TARGET_ARCH} \"" "\" COPTO = /Fo \"" "\" LOPTO = /OUT: \"" "\" ${TARGET_MOL_SETTINGS} \"" "\" DEF = ${TARGET_DEF} \"" "\" AR = ${TARGET_AR} \"" "\" NM = ${TARGET_NM} \"" "\" RANLIB = ${TARGET_RANLIB} \"" "\" SHLDFLAGS = ${TARGET_SHLDFLAGS} \"" "\"${TARGET_MOL_LIBS}\""
COMMENT "Compiling libmolfile_plugin.a"
WORKING_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/../molfile_plugin"
)
endif()
add_custom_target(molfile_plugins_comp ALL
DEPENDS ${LIB_MOLFILE_FILES}
)
#add_executable(myexecutable myexcutable.c)
#target_link_libraries(myexecutable vmd_molfile_plugins/compile/lib_MACOSXX86_64GCCTNG/molfile/libmolfile_plugins.a)
#add_dependencies(myexecutable extern_lib)
#add_library(molfile_plugins INTERFACE)
#target_include_directories(molfile_plugins INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/lib/")
#target_link_libraries(molfile_plugins INTERFACE ${MOLFILE_LIBRARIES})
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment