Skip to content

Commit

Permalink
Merge pull request #201 from openmopac/fix-build-type
Browse files Browse the repository at this point in the history
Fix Windows build type problem
  • Loading branch information
godotalgorithm authored Apr 22, 2024
2 parents ab3674c + bef9537 commit e7a5c3f
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,25 @@ endif()
file(READ "CITATION.cff" CITATION)
string(REGEX MATCH "[^-]version: ([0-9\.]*)" _ ${CITATION})

# Code coverage option
option(ENABLE_COVERAGE "Code coverage flag" OFF)

# Set a safe default build type if there is no user input
if(NOT CMAKE_BUILD_TYPE)
if (ENABLE_COVERAGE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
else()
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
else()
# otherwise, check conflict with ENABLE_COVERAGE
if(ENABLE_COVERAGE AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
message(FATAL_ERROR "Option ENABLE_COVERAGE requires CMAKE_BUILD_TYPE=Debug")
endif()
endif()

message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")

# Specify project name & programming languages
project(openmopac VERSION ${CMAKE_MATCH_1} LANGUAGES Fortran)

Expand Down Expand Up @@ -61,25 +80,6 @@ else()
message(STATUS "Shared library and dynamic executables")
endif()

# Code coverage option
option(ENABLE_COVERAGE "Code coverage flag" OFF)

# Set a safe default build type if there is no user input
if(NOT CMAKE_BUILD_TYPE)
if (ENABLE_COVERAGE)
set(CMAKE_BUILD_TYPE Debug CACHE STRING "Choose the type of build." FORCE)
else()
set(CMAKE_BUILD_TYPE Release CACHE STRING "Choose the type of build." FORCE)
endif()
else()
# otherwise, check conflict with ENABLE_COVERAGE
if(ENABLE_COVERAGE AND NOT ${CMAKE_BUILD_TYPE} STREQUAL "Debug")
message(FATAL_ERROR "Option ENABLE_COVERAGE requires CMAKE_BUILD_TYPE=Debug")
endif()
endif()

message(STATUS "Build type is ${CMAKE_BUILD_TYPE}")

# location for CMake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")

Expand Down

0 comments on commit e7a5c3f

Please sign in to comment.