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

Combining CMake files

parent c6feda88
cmake_minimum_required(VERSION 2.8.12)
project(molfileplugins)
find_package(EXPAT)
find_package(NetCDF)
find_package(TCL)
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}")
else()
set(TARGET_ARCH ${CMAKE_HOST_SYSTEM_PROCESSOR})
endif()
message(TARGET_ARCH= ${TARGET_ARCH})
message(SYS_VER= ${CMAKE_SYSTEM_VERSION})
message(SYS_NAME= ${CMAKE_SYSTEM_NAME})
message(SYS_PROC= ${CMAKE_SYSTEM_PROCESSOR})
message(SYS= ${CMAKE_SYSTEM})
if(TARGET_ARCH MATCHES "^.*64.*$")
set(ARCH64BIT TRUE)
endif()
set(LIB_MOLFILE_FILES
"${CMAKE_CURRENT_BINARY_DIR}/lib/libmolfile_plugins.a"
"${CMAKE_CURRENT_BINARY_DIR}/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 " -fPIC -m64 -o ")
set(TARGET_LOPT " -fPIC -m64 -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 "-l${TCL_LIBRARY}")
set(TCLINC "-I${TCL_INCLUDE_PATH}")
set(TCLLIB "-I${TCL_INCLUDE_PATH}")
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()
message(MOL_C= "${CMAKE_C_COMPILER}")
message(MOL_CXX= "${CMAKE_CXX_COMPILER}")
message(MOL_CFLAGS= "${CMAKE_C_FLAGS}")
message(MOL_CXXFLAGS= "${CMAKE_CXX_FLAGS}")
add_custom_command(
OUTPUT ${LIB_MOLFILE_FILES}
COMMAND make dynlibs staticlibs "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_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_library(molfile_plugins INTERFACE)
target_include_directories(molfile_plugins INTERFACE "${CMAKE_CURRENT_BINARY_DIR}/lib/")
target_link_libraries(molfile_plugins INTERFACE ${MOLFILE_LIBRARIES})
#add_dependencies(molfile_plugin_comp)
......@@ -130,21 +130,18 @@ if __name__ == '__main__':
],
swig_opts=['-py3', '-Wall', '-c++'],
library_dirs=[
'pymolfile/molfile/lib/',
'pymolfile/molfile/lib/tng/lib/'
'pymolfile/molfile/external/tng/lib/',
'pymolfile/molfile/molfile_plugins/compile/lib/'
],
libraries=['netcdf','tng_io','expat'],
include_dirs = [
get_numpy_include(),
get_numpy_include(),
get_cmake_includes(),
'pymolfile/molfile',
'pymolfile/molfile/lib/'
'pymolfile/molfile/include/',
'pymolfile/molfile/include/molfile_plugin/include',
'pymolfile/molfile/lib/molfile_plugin/lib',
'pymolfile/molfile/include/plugin_src/include',
#'pymolfile/molfile/include/netcdf/include',
#'pymolfile/molfile/include/expat/include',
'pymolfile/molfile/include/tng/include',
'pymolfile/molfile/molfile_plugins/include',
'pymolfile/molfile/molfile_plugins/molfile_plugin/include',
'pymolfile/molfile/molfile_plugins/compile/lib/',
'pymolfile/molfile/external/tng/include',
],
extra_compile_args = [
'-fPIC', '-shared', '-O2', '-w'
......@@ -152,7 +149,7 @@ if __name__ == '__main__':
#'-fPIC', '-O2', '-w', '-fmessage-length=0'
],
extra_link_args = [
'pymolfile/molfile/lib/molfile_plugin/lib/libmolfile_plugin.a'
'pymolfile/molfile/molfile_plugins/compile/lib/libmolfile_plugin.a'
],
define_macros = largefile_macros
)
......
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