Skip to content

Commit

Permalink
Use OpenCogGccOptions.cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
linas committed Mar 11, 2020
1 parent 4e4cbbe commit 2f3d8a5
Showing 1 changed file with 1 addition and 53 deletions.
54 changes: 1 addition & 53 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -49,59 49,6 @@ MESSAGE(STATUS "Build type: ${CMAKE_BUILD_TYPE}")
ADD_DEFINITIONS(-DPROJECT_SOURCE_DIR="${CMAKE_SOURCE_DIR}"
-DPROJECT_BINARY_DIR="${CMAKE_BINARY_DIR}")

# ===============================================================
# Detect different compilers and OS'es, tweak flags as necessary.

IF (CMAKE_COMPILER_IS_GNUCXX)
# Atomspace is already asking for version 5.0, so ask for that.
IF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)
MESSAGE(FATAL_ERROR "GCC version must be at least 5.0!")
ENDIF (CMAKE_CXX_COMPILER_VERSION VERSION_LESS 5.0)

IF (APPLE)
SET(CMAKE_C_FLAGS "-Wall -Wno-long-long -Wno-conversion")
SET(CMAKE_C_FLAGS_DEBUG "-O0 -g")
SET(CMAKE_C_FLAGS_PROFILE "-O0 -pg")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -g0")
# Vital to do this otherwise unresolved symbols everywhere:
SET(CMAKE_SHARED_LINKER_FLAGS "-Wl,-flat_namespace,-undefined,dynamic_lookup")
SET(CMAKE_EXE_LINKER_FLAGS "-Wl,-flat_namespace,-undefined,dynamic_lookup")

# The Apple linker does not support the --no-as-needed flag.
SET(NO_AS_NEEDED "")

ELSE (APPLE)
SET(CMAKE_C_FLAGS "-Wall -fPIC")
# SET(CMAKE_C_FLAGS "-Wl,--copy-dt-needed-entries")
SET(CMAKE_C_FLAGS_DEBUG "-ggdb3 -fstack-protector")
SET(CMAKE_C_FLAGS_PROFILE "-O2 -g3 -fstack-protector -pg")
SET(CMAKE_C_FLAGS_RELEASE "-O2 -g -fstack-protector")

SET(NO_AS_NEEDED "-Wl,--no-as-needed")
ENDIF (APPLE)

# 1) -Wno-variadic-macros is to avoid warnings regarding using
# variadic in macro OC_ASSERT (the warning warns that this is only
# available from C99, lol!)
#
# 2) -fopenmp for multithreading support
#
# 3) -std=gnu 11 for C 11 and GNU extensions support
SET(CMAKE_CXX_FLAGS "${CMAKE_C_FLAGS} -Wno-variadic-macros -fopenmp -std=gnu 11")

SET(CMAKE_CXX_FLAGS_DEBUG ${CMAKE_C_FLAGS_DEBUG})
SET(CMAKE_CXX_FLAGS_PROFILE ${CMAKE_C_FLAGS_PROFILE})
SET(CMAKE_CXX_FLAGS_RELEASE ${CMAKE_C_FLAGS_RELEASE})

# Options for generating gcov code coverage output
SET(CMAKE_C_FLAGS_COVERAGE "-O0 -g -fprofile-arcs -ftest-coverage -fno-inline")
SET(CMAKE_CXX_FLAGS_COVERAGE "${CMAKE_C_FLAGS_COVERAGE} -fno-default-inline")
# Might be needed for some combinations of ln and gcc
IF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
LINK_LIBRARIES(gcov)
ENDIF (CMAKE_BUILD_TYPE STREQUAL "Coverage")
ENDIF (CMAKE_COMPILER_IS_GNUCXX)

# ===============================================================
# Check for existance of various required, optional packages.
# Listed in alphabetical order, more or less.
Expand All @@ -120,6 67,7 @@ ENDIF (COGUTIL_FOUND)
# add the 'cmake' directory from cogutil to search path
list(APPEND CMAKE_MODULE_PATH ${COGUTIL_DATA_DIR}/cmake)

include(${COGUTIL_DATA_DIR}/cmake/OpenCogGccOptions.cmake)
include(${COGUTIL_DATA_DIR}/cmake/Summary.cmake)

# ===================================================================
Expand Down

0 comments on commit 2f3d8a5

Please sign in to comment.