CMakeLists.txt 2.58 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22
cmake_minimum_required(VERSION 2.8)
# Set policy: link_directories is relative to source dir
cmake_policy(SET CMP0015 NEW)


# Set the project name.
project(ERUTA C)

# Play with PCC
# SET(CMAKE_C_COMPILER   /usr/local/bin/pcc)
# Play with UCC
# SET(CMAKE_C_COMPILER   /usr/local/lib/ucc/ucc)

# tell CMake to search first in the cmake subdirectory for FIND_PACKAGE() or INCLUDE()
set(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake/)

include(CheckCSourceCompiles)
include(CheckCXXSourceCompiles)


if(CMAKE_COMPILER_IS_GNUCC)
set(COMPILER_GCC 1)
23
set(CMAKE_C_FLAGS "-W -Wall -Wno-unused -Wno-unknown-pragmas -g3 -gdwarf-2 -std=c99 -ffast-math -fsanitize=address -fno-omit-frame-pointer -fstrict-aliasing -Wstrict-aliasing=2")
24 25 26 27
# set(CMAKE_LD_FLAGS "-pg")
# always use gnu99, debugging, all warnings except unused and unknown pragmas.
# when compiling with gnu compiler.  
# Warn about alisasing because otherwise aliasing problems it may not be detected.
28 29
else(CMAKE_COMPILER_IS_GNUCC)
set(CMAKE_C_FLAGS "-W -Wall -Wno-unused -Wno-unknown-pragmas -g -std=c99 -ffast-math -fstrict-aliasing -Wstrict-aliasing=2")
30 31 32 33 34
endif(CMAKE_COMPILER_IS_GNUCC)

# or for PCC
# set(CMAKE_C_FLAGS "-fpic -fPIC")  

35

36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51

find_package(Mruby REQUIRED)

# Finds Allegro using pkgconfig, so it must be configured correctly 
find_package(Allegro5 REQUIRED)

find_package(PNG REQUIRED)
find_package(JPEG REQUIRED)

# Set include and lib dirs. 
include_directories(${ALLEGRO_INCLUDE_DIR} ${PNG_INCLUDE_DIR} ${JPEG_INCLUDE_DIR} ${MRUBY_INCLUDE_DIR}) 


set(ERUTA_LIBS ${LIBS} ${OBJC_LIBRARIES} ${ALLEGRO_LIBRARIES} ${PNG_LIBRARY} ${JPEG_LIBRARY} ${MRUBY_LIBRARIES})

include_directories("include")
52 53
include_directories("include/zori")
include_directories("include/tr")
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
# add_subdirectory("src")
include(ErutaFiles)
set_source_files_properties(${ERUTA_SRC_FILES} PROPERTIES LANGUAGE C)

# set_source_files_properties(${ERUTA_OBJC_SRC_FILES} PROPERTIES LANGUAGE C)
# src/BNObject.m 
# set_source_files_properties(BNObject.m PROPERTIES LANGUAGE C)




# eruta exe in the bin subdir (first one should work, but doesnt, hmmm...)
set(RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin)
set(EXECUTABLE_OUTPUT_PATH ${CMAKE_BINARY_DIR}/bin)
add_library(ERUTA_OBJECTS OBJECT ${ERUTA_SRC_FILES})
add_executable(eruta $<TARGET_OBJECTS:ERUTA_OBJECTS> src/main.c)
target_link_libraries(eruta ${ERUTA_LIBS})

enable_testing()
# Let ctest run valgrind
# test exe in the test subdir (first one should work, but doesnt, hmmm...)
set(CMAKE_CTEST_OPTIONS --output-on-failure)
set(CTEST_OUTPUT_ON_FAILURE TRUE)
set(CTEST_MEMORYCHECK_COMMAND:FILEPATH "/usr/bin/valgrind")
add_subdirectory("test")