Skip to content

Commit

Permalink
Merged in refactoring (pull request #1)
Browse files Browse the repository at this point in the history
Refactoring

Approved-by: xin cao
Approved-by: Andrey Alekseenko
  • Loading branch information
ignatovmg committed Aug 13, 2020
2 parents 2452d6a + c9809bd commit df52f46
Show file tree
Hide file tree
Showing 86 changed files with 36,742 additions and 56,575 deletions.
41 changes: 2 additions & 39 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,48 +1,20 @@
# Project custom
sandbox/
.idea/

# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839

# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf

# Generated files
.idea/**/contentModel.xml

# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml

# Gradle
.idea/**/gradle.xml
.idea/**/libraries

# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# *.iml
# *.ipr

# CMake
cmake-build-*/

# Mongo Explorer plugin
.idea/**/mongoSettings.xml

# File-based project format
*.iws

Expand All @@ -55,17 +27,8 @@ out/
# JIRA plugin
atlassian-ide-plugin.xml

# Cursive Clojure plugin
.idea/replstate.xml

# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties

# Editor-based Rest Client
.idea/httpRequests

# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
fabric.properties
128 changes: 115 additions & 13 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,18 +1,120 @@
cmake_minimum_required(VERSION 3.5)
project(energymin LANGUAGES C)
set(energymin_version_major 0)
set(energymin_version_minor 0)
set(energymin_version "${energymin_version_major}.${energymin_version_minor}")
cmake_minimum_required(VERSION 3.9)

if(${CMAKE_VERSION} VERSION_LESS 3.12)
cmake_policy(VERSION ${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION})
endif()

cmake_policy(SET CMP0069 NEW)

project(NRGmin VERSION 1.0
DESCRIPTION "Energy minimization utility"
LANGUAGES C)

set(CMAKE_C_STANDARD 11)
set(CMAKE_C_STANDARD_REQUIRED ON)
set(CMAKE_C_EXTENSIONS OFF)

option(BUILD_TESTS "Build tests" ON)
option(USE_LTO "Link Time Optimization" ON)
option(USE_SANITIZER "Build with address sanitizer" OFF)
option(OPENMP "Add OPENMP executable" OFF)
option(NOE "Build with NOE feature" ON)

set(CMAKE_MODULE_PATH "${CMAKE_SOURCE_DIR}/cmake/")

set(CMAKE_C_FLAGS "-std=c11 -fPIC ${CMAKE_C_FLAGS}")
set(CMAKE_C_FLAGS_DEBUG "-Wall ${CMAKE_C_FLAGS_DEBUG}")
set(CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE}")
if (UNIX AND CMAKE_BUILD_TYPE STREQUAL "Debug")
add_compile_options(-pg -Wall -Wshadow -Wpointer-arith -Wcast-qual -Winline -Werror -Wextra -Wfatal-errors -Wstrict-prototypes)
endif()

if (USE_SANITIZER)
set(SANITIZER_FLAGS "-fno-omit-frame-pointer -fsanitize=address,undefined")
add_compile_options(${SANITIZER_FLAGS})
add_link_options(${SANITIZER_FLAGS})
endif()

if (NOE)
add_definitions(-D NOE)
endif()

find_package(Jansson REQUIRED)

find_package(mol2 REQUIRED)

set(LIBRARY_LIST
"${MOL2_LIBRARIES}"
"${JANSSON_LIBRARIES}"
m)

set(INCLUDE_LIST
"${MOL2_INCLUDE_DIRS}"
"${JANSSON_INCLUDE_DIRS}")

# Read help text from the file and plug it in parse_options.c.in
file(STRINGS ${PROJECT_SOURCE_DIR}/src/usage.txt USAGE_LINES)
# Join lines using "\" character. Can't use string(JOIN ..) here,
# because it exists only in the newer versions of cmake
set(USAGE_TEXT "")
list(LENGTH USAGE_LINES USAGE_N_LINES)
math(EXPR USAGE_LAST_LINE "${USAGE_N_LINES} - 1")
foreach(LINE_ID RANGE ${USAGE_LAST_LINE})
list(GET USAGE_LINES ${LINE_ID} LINE)
set(USAGE_TEXT "${USAGE_TEXT}\\n${LINE}")
endforeach()
configure_file (
"${PROJECT_SOURCE_DIR}/src/parse_options.c.in"
"${PROJECT_BINARY_DIR}/parse_options.c"
)

set(SRC_LIST
${PROJECT_SOURCE_DIR}/src/setup.c
${PROJECT_SOURCE_DIR}/src/utils.c
${PROJECT_SOURCE_DIR}/src/energy.c
${PROJECT_BINARY_DIR}/parse_options.c)

add_executable(nrgmin ${PROJECT_SOURCE_DIR}/src/minimize.c ${SRC_LIST})

if (USE_LTO)
include(CheckIPOSupported)
check_ipo_supported(RESULT result)
if(NOT result)
set(USE_LTO OFF)
endif()
endif()

if (USE_LTO)
set_target_properties(nrgmin PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

target_include_directories(nrgmin
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>"
PRIVATE ${INCLUDE_LIST})

target_link_libraries(nrgmin ${LIBRARY_LIST})

if (OPENMP)
find_package(OpenMP REQUIRED)

add_executable(nrgmin.omp ${PROJECT_SOURCE_DIR}/src/minimize.c ${SRC_LIST})

if (USE_LTO)
set_target_properties(nrgmin.omp PROPERTIES INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()

target_include_directories(nrgmin.omp
PUBLIC
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/src>"
"$<INSTALL_INTERFACE:${INCLUDE_INSTALL_DIR}>"
PRIVATE ${INCLUDE_LIST})

include_directories($ENV{HOME}/include)
link_directories($ENV{HOME}/lib)
target_link_libraries(nrgmin.omp ${LIBRARY_LIST} OpenMP::OpenMP_C)

find_package(GSL REQUIRED)
target_compile_definitions(nrgmin.omp PUBLIC OPENMP)
endif()

add_executable(minimize minimize.c)
target_link_libraries(minimize mol2 nmrgrad ${GSL_LIBRARIES} jansson m)
if (BUILD_TESTS)
find_package(Check REQUIRED)
enable_testing()
add_subdirectory("test")
endif()
21 changes: 0 additions & 21 deletions LICENSE

This file was deleted.

Loading

0 comments on commit df52f46

Please sign in to comment.