cmake_minimum_required (VERSION 2.8) project(SuperSimpleTypeSystem) option (DEBUG "Enable debug flags and macros in project" TRUE) find_package (Threads REQUIRED) if (CMAKE_USE_WIN32_THREADS_INIT) set (HAVE_MTHREAD ON) set (HAVE_PTHREAD OFF) elseif (CMAKE_USE_PTHREADS_INIT) set (HAVE_PTHREAD ON) set (HAVE_MTHREAD OFF) else () set (HAVE_PTHREAD OFF) set (HAVE_MTHREAD OFF) endif () if (WIN32) if (MINGW) message ("Compiling on Windows is undested.") # THIS IS UNTESTED. # On Wine (and, presumably ReactOS) (Using MingW) we need to pass -gdwarf-2 # to ba able to get traceback information. This is not ideal. # On Windows we need to use cv2pdb (https://github.com/rainers/cv2pdb) to # provide debug information. # This can not be tested using cross-compile methods with MingW and Wine. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -std=c11 -mthreads -Wall -gdwarf-2 -pthread") set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -std=c11 -mthreads -Wall -g -gdwarf-2") set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -std=c11 -mthreads -Wall -gdwarf-2 ") elseif (MSVC) message ("MSVC is not supported, Yet. Patches welcome!") endif () else () add_definitions(-D_POSIX_C_SOURCE=199309L -D_GNU_SOURCE) # We need -rdynamic to get the traceback information on *nix. # This may not work on all non-windows targets. FIXME. set (CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -pthread -std=c11 -Wall -rdynamic -fstack-protector-strong") set (CMAKE_C_FLAGS_DEBUG "${CMAKE_C_FLAGS_DEBUG} -pthread -std=c11 -Wall -g -rdynamic -fstack-protector-strong") set (CMAKE_C_FLAGS_RELEASE "${CMAKE_C_FLAGS_RELEASE} -pthread -std=c11 -Wall -rdynamic -fstack-protector-strong") endif () # add a target to generate API documentation with Doxygen find_package(Doxygen) if(DOXYGEN_FOUND) configure_file(${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(doc ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" VERBATIM ) endif(DOXYGEN_FOUND) add_subdirectory (src) include_directories (${CMAKE_SOURCE_DIR}/src/) add_subdirectory (tests) add_library (ssts SHARED ${SSTS_SRC}) target_link_libraries (ssts ${CMAKE_THREAD_LIBS_INIT}) message (${CMAKE_THREAD_LIBS_INIT}) enable_testing() add_test (test tests/ssts_test ) add_custom_target(check COMMAND ${CMAKE_CTEST_COMMAND} --extra-verbose)