Skip to content
Browse files

Add CMake files

  • Loading branch information...
1 parent 730325c commit 01e2eb10a9a2ca7d56bfe83d04140078d1271fda @certik committed Feb 24, 2012
Showing with 76 additions and 0 deletions.
  1. +42 −0 CMakeLists.txt
  2. +18 −0 cmake/UserOverride.cmake
  3. +16 −0 src/CMakeLists.txt
View
42 CMakeLists.txt
@@ -0,0 +1,42 @@
+cmake_minimum_required(VERSION 2.6 FATAL_ERROR)
+
+set(CMAKE_USER_MAKE_RULES_OVERRIDE ${CMAKE_SOURCE_DIR}/cmake/UserOverride.cmake)
+
+project(minpack)
+enable_language(Fortran)
+
+set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
+
+# Make sure that CMAKE_BUILD_TYPE is either Debug or Release:
+if (NOT CMAKE_BUILD_TYPE)
+ set(CMAKE_BUILD_TYPE Debug
+ CACHE STRING "Build type (Debug, Release)" FORCE)
+endif ()
+if (NOT (CMAKE_BUILD_TYPE STREQUAL "Debug" OR
+ CMAKE_BUILD_TYPE STREQUAL "Release"))
+ message("${CMAKE_BUILD_TYPE}")
+ message(FATAL_ERROR "CMAKE_BUILD_TYPE must be one of: Debug, Release (current value: '${CMAKE_BUILD_TYPE}')")
+endif ()
+
+if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
+ # gfortran
+ # Enable this if you want to check for single/double corruption (and use
+ # the Debug build):
+ #set(CMAKE_Fortran_FLAGS_DEBUG "${CMAKE_Fortran_FLAGS_DEBUG} -fdefault-real-8")
+endif ()
+
+
+#add_subdirectory(examples)
+add_subdirectory(src)
+
+message("\n")
+message("Configuration results")
+message("---------------------")
+message("Fortran compiler: ${CMAKE_Fortran_COMPILER}")
+message("Build type: ${CMAKE_BUILD_TYPE}")
+if (CMAKE_BUILD_TYPE STREQUAL "Debug")
+ message("Fortran compiler flags: ${CMAKE_Fortran_FLAGS_DEBUG}")
+else ()
+ message("Fortran compiler flags: ${CMAKE_Fortran_FLAGS_RELEASE}")
+endif ()
+message("Installation prefix: ${CMAKE_INSTALL_PREFIX}")
View
18 cmake/UserOverride.cmake
@@ -0,0 +1,18 @@
+# This overrides the default CMake Debug and Release compiler options.
+# The user can still specify different options by setting the
+# CMAKE_Fortran_FLAGS_[RELEASE,DEBUG] variables (on the command line or in the
+# CMakeList.txt). This files serves as better CMake defaults and should only be
+# modified if the default values are to be changed. Project specific compiler
+# flags should be set in the CMakeList.txt by setting the CMAKE_Fortran_FLAGS_*
+# variables.
+if (CMAKE_Fortran_COMPILER_ID STREQUAL "GNU")
+ # gfortran
+ set(common "-std=f2003 -Wall -Wextra -Wimplicit-interface -Werror -fPIC -fmax-errors=1")
+ set(CMAKE_Fortran_FLAGS_RELEASE_INIT "${common} -O3 -march=native -ffast-math -funroll-loops")
+ set(CMAKE_Fortran_FLAGS_DEBUG_INIT "${common} -g -fbounds-check -fcheck-array-temporaries -fbacktrace")
+elseif (CMAKE_Fortran_COMPILER_ID STREQUAL "Intel")
+ # ifort
+ set(common "-std2003 -warn all")
+ set(CMAKE_Fortran_FLAGS_RELEASE_INIT "${common} -xHOST -O3 -no-prec-div -static")
+ set(CMAKE_Fortran_FLAGS_DEBUG_INIT "${common} -check all")
+endif ()
View
16 src/CMakeLists.txt
@@ -0,0 +1,16 @@
+set(SRC
+ covar.f errjac.f hybipt.f lhesfcn.f lmdipt.f ocpipt.f r1updt.f
+ vecjac.f
+ dmchar.f fdjac1.f hybrd1.f lmder1.f lmpar.f qform.f rwupdt.f
+ dogleg.f fdjac2.f hybrd.f lmder.f lmstr1.f qrfac.f ssqfcn.f
+ dpmpar.f grdfcn.f hybrj1.f lmdif1.f lmstr.f qrsolv.f ssqjac.f
+ enorm.f hesfcn.f hybrj.f lmdif.f objfcn.f r1mpyq.f vecfcn.f
+)
+
+add_definitions(-std=legacy -Wno-implicit-interface)
+add_library(minpack ${SRC})
+install(TARGETS minpack
+ RUNTIME DESTINATION bin
+ ARCHIVE DESTINATION lib
+ LIBRARY DESTINATION lib
+ )

0 comments on commit 01e2eb1

Please sign in to comment.
Something went wrong with that request. Please try again.