Commit 3e9b2141 authored by Ghislain MARY's avatar Ghislain MARY

Enable compilation of CUnit using CMake.

parent 98890b69
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
cmake_minimum_required(VERSION 2.8)
project(CUNIT C)
set(PACKAGE "CUnit")
set(PACKAGE_NAME "${PACKAGE}")
set(PACKAGE_VERSION "2.1-2")
set(PACKAGE_STRING "${PACKAGE_NAME} ${PACKAGE_VERSION}")
set(PACKAGE_BUGREPORT "")
set(PACKAGE_TARNAME "cunit")
set(PACKAGE_URL "")
set(VERSION "${PACKAGE_VERSION}")
option(ENABLE_AUTOMATED "Compile CUnit automated interface" ON)
option(ENABLE_BASIC "Compile CUnit basic interface" ON)
option(ENABLE_CONSOLE "Compile CUnit console interface" ON)
option(ENABLE_CURSES "Compile CUnit curses interface" OFF)
option(ENABLE_EXAMPLES "Compile CUnit example programs" OFF)
option(ENABLE_TEST "Compile CUnit internal test program" OFF)
option(ENABLE_MEMTRACE "Enable CUnit internal memory tracking" OFF)
option(ENABLE_DEPRECATED "Enable use of deprecated v1.1 names" OFF)
include(CheckIncludeFile)
include(CheckFunctionExists)
check_include_file("assert.h" HAVE_ASSERT_H)
check_include_file("ctype.h" HAVE_CTYPE_H)
check_include_file("dlfcn.h" HAVE_DLFCN_H)
check_include_file("file.h" HAVE_FILE_H)
check_include_file("inttypes.h" HAVE_INTTYPES_H)
check_include_file("math.h" HAVE_MATH_H)
check_include_file("memory.h" HAVE_MEMORY_H)
check_include_file("stdint.h" HAVE_STDINT_H)
check_include_file("stdio.h" HAVE_STDIO_H)
check_include_file("stdlib.h" HAVE_STDLIB_H)
check_include_file("strings.h" HAVE_STRINGS_H)
check_include_file("string.h" HAVE_STRING_H)
check_include_file("sys/stat.h" HAVE_SYS_STAT_H)
check_include_file("sys/types.h" HAVE_SYS_TYPES_H)
check_include_file("unistd.h" HAVE_UNISTD_H)
macro(check_function_exists_fail FUNCTION)
string(TOUPPER ${FUNCTION} UPPER_FUNCTION)
check_function_exists("${FUNCTION}" HAVE_${UPPER_FUNCTION})
if(NOT ${HAVE_${UPPER_FUNCTION}})
message(FATAL_ERROR "${FUNCTION} not found")
endif(NOT ${HAVE_${UPPER_FUNCTION}})
endmacro(check_function_exists_fail)
check_function_exists_fail("malloc")
check_function_exists_fail("free")
check_function_exists_fail("calloc")
check_function_exists_fail("realloc")
check_function_exists_fail("strcpy")
check_function_exists_fail("strerror")
check_function_exists_fail("fopen")
check_function_exists_fail("fclose")
check_function_exists_fail("fprintf")
check_function_exists_fail("snprintf")
check_function_exists_fail("setvbuf")
check_function_exists_fail("time")
check_function_exists_fail("ctime")
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/config.h.cmake ${CMAKE_CURRENT_BINARY_DIR}/config.h)
set(prefix ${CMAKE_INSTALL_PREFIX})
set(exec_prefix ${prefix}/bin)
set(libdir ${prefix}/lib)
set(includedir ${prefix}/include)
configure_file(${CMAKE_CURRENT_SOURCE_DIR}/cunit.pc.in ${CMAKE_CURRENT_BINARY_DIR}/cunit.pc)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/cunit.pc DESTINATION lib/pkgconfig)
add_definitions(-Wall -W -pedantic -Wshadow -ansi -std=c99)
if(${ENABLE_MEMTRACE})
add_definitions(-DMEMTRACE)
endif(${ENABLE_MEMTRACE})
if(${ENABLE_DEPRECATED})
add_definitions(-DUSE_DEPRECATED_CUNIT_NAMES)
endif(${ENABLE_DEPRECATED})
if(${ENABLE_CURSES})
set(CURSES_NEED_NCURSES 1)
find_package(Curses)
if(NOT ${CURSES_FOUND})
message("Disabling curses as it has not been found!")
set(ENABLE_CURSES 0)
endif(NOT ${CURSES_FOUND})
endif(${ENABLE_CURSES})
include_directories(
CUnit/Headers
${CMAKE_CURRENT_BINARY_DIR}
)
add_subdirectory(CUnit)
add_subdirectory(doc)
add_subdirectory(Man)
add_subdirectory(Share)
if(${ENABLE_EXAMPLES})
add_subdirectory(Examples)
endif(${ENABLE_EXAMPLES})
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
add_subdirectory(Sources)
add_subdirectory(Headers)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
set(AUTOMATED_INCLUDES Automated.h)
set(BASIC_INCLUDES Basic.h)
set(CONSOLE_INCLUDES Console.h)
set(CURSES_INCLUDES CUCurses.h)
set(FRAMEWORK_INCLUDES CUError.h CUnit.h CUnit_intl.h MyMem.h TestDB.h TestRun.h Util.h)
set(HEADER_FILES ${FRAMEWORK_INCLUDES})
if(${ENABLE_BASIC})
list(APPEND HEADER_FILES ${BASIC_INCLUDE_FILES})
endif(${ENABLE_BASIC})
if(${ENABLE_CONSOLE})
list(APPEND HEADER_FILES ${CONSOLE_INCLUDE_FILES})
endif(${ENABLE_CONSOLE})
if(${ENABLE_AUTOMATED})
list(APPEND HEADER_FILES ${AUTOMATED_INCLUDE_FILES})
endif(${ENABLE_AUTOMATED})
if(${ENABLE_CURSES})
list(APPEND HEADER_FILES ${CURSES_INCLUDE_FILES})
endif(${ENABLE_CURSES})
install(FILES ${HEADER_FILES}
DESTINATION include/CUnit
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
set(BASIC_SOURCE_FILES Basic/Basic.c)
set(AUTOMATED_SOURCE_FILES Automated/Automated.c)
set(CONSOLE_SOURCE_FILES Console/Console.c)
set(CURSES_SOURCE_FILES Curses/Curses.c)
set(FRAMEWORK_SOURCE_FILES
Framework/CUError.c
Framework/MyMem.c
Framework/TestDB.c
Framework/TestRun.c
Framework/Util.c
)
set(SOURCE_FILES ${FRAMEWORK_SOURCE_FILES})
source_group(framework FILES ${FRAMEWORK_SOURCE_FILES})
if(${ENABLE_BASIC})
list(APPEND SOURCE_FILES ${BASIC_SOURCE_FILES})
source_group(basic FILES ${BASIC_SOURCE_FILES})
endif(${ENABLE_BASIC})
if(${ENABLE_AUTOMATED})
list(APPEND SOURCE_FILES ${AUTOMATED_SOURCE_FILES})
source_group(automated FILES ${AUTOMATED_SOURCE_FILES})
endif(${ENABLE_AUTOMATED})
if(${ENABLE_CONSOLE})
list(APPEND SOURCE_FILES ${CONSOLE_SOURCE_FILES})
source_group(console FILES ${CONSOLE_SOURCE_FILES})
endif(${ENABLE_CONSOLE})
if(${ENABLE_CURSES})
list(APPEND SOURCE_FILES ${CURSES_SOURCE_FILES})
source_group(curses FILES ${CURSES_SOURCE_FILES})
endif(${ENABLE_CURSES})
if(${ENABLE_STATIC})
add_library(cunit STATIC ${SOURCE_FILES})
target_link_libraries(cunit ${CURSES_LIBRARIES})
else(${ENABLE_STATIC})
add_library(cunit SHARED ${SOURCE_FILES})
set_target_properties(cunit PROPERTIES SOVERSION 1.0.1 VERSION 1)
target_link_libraries(cunit ${CURSES_LIBRARIES})
if(MSVC)
if(CMAKE_BUILD_TYPE STREQUAL "Debug")
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/Debug/cunit.pdb
DESTINATION bin
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
endif()
endif(MSVC)
endif(${ENABLE_STATIC})
install(TARGETS cunit
RUNTIME DESTINATION bin
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib
PERMISSIONS OWNER_READ OWNER_WRITE OWNER_EXECUTE GROUP_READ GROUP_EXECUTE WORLD_READ WORLD_EXECUTE
)
if(${ENABLE_TEST})
add_library(cunit_test STATIC ${FRAMEWORK_SOURCE_FILES})
target_compile_definitions(cunit_test PUBLIC MEMTRACE CUNIT_BUILD_TESTS CUNIT_DO_NOT_DEFINE_UNLESS_BUILDING_TESTS)
target_include_directories(cunit_test PUBLIC Test)
add_subdirectory(Test)
endif(${ENABLE_TEST})
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
add_executable(test_cunit test_cunit.c)
target_link_libraries(test_cunit cunit_test)
target_compile_definitions(test_cunit PUBLIC MEMTRACE CUNIT_BUILD_TESTS CUNIT_DO_NOT_DEFINE_UNLESS_BUILDING_TESTS)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
add_executable(AutomatedTest AutomatedTest.c)
target_link_libraries(AutomatedTest cunit cunitexamples)
install(TARGETS AutomatedTest DESTINATION share/CUnit/Examples/Automated)
install(FILES README DESTINATION share/CUnit/Examples/Automated)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
add_executable(BasicTest BasicTest.c)
target_link_libraries(BasicTest cunit cunitexamples)
install(TARGETS BasicTest DESTINATION share/CUnit/Examples/Basic)
install(FILES README DESTINATION share/CUnit/Examples/Basic)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
add_library(cunitexamples STATIC ExampleTests.c)
include_directories(${CMAKE_CURRENT_SOURCE_DIR})
if(${ENABLE_BASIC})
add_subdirectory(BasicTest)
endif(${ENABLE_BASIC})
if(${ENABLE_CONSOLE})
add_subdirectory(ConsoleTest)
endif(${ENABLE_CONSOLE})
if(${ENABLE_CURSES})
add_subdirectory(CursesTest)
endif(${ENABLE_CURSES})
if(${ENABLE_AUTOMATED})
add_subdirectory(AutomatedTest)
endif(${ENABLE_AUTOMATED})
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
add_executable(ConsoleTest ConsoleTest.c)
target_link_libraries(ConsoleTest cunit cunitexamples)
install(TARGETS ConsoleTest DESTINATION share/CUnit/Examples/Console)
install(FILES README DESTINATION share/CUnit/Examples/Console)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
add_executable(CursesTest CursesTest.c)
target_link_libraries(CursesTest cunit cunitexamples)
install(TARGETS CursesTest DESTINATION share/CUnit/Examples/Curses)
install(FILES README DESTINATION share/CUnit/Examples/Curses)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
install(FILES man3/CUnit.3
DESTINATION share/man/man3
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
set(SHARE_FILES
CUnit-List.dtd
CUnit-List.xsl
CUnit-Run.dtd
CUnit-Run.xsl
Memory-Dump.dtd
Memory-Dump.xsl
)
install(FILES ${SHARE_FILES}
DESTINATION share/CUnit
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
/***************************************************************************
* antlr3config.h.cmake
* Copyright (C) 2014 Belledonne Communications, Grenoble France
*
****************************************************************************
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*
****************************************************************************/
#cmakedefine PACKAGE "@PACKAGE@"
#cmakedefine PACKAGE_NAME "@PACKAGE_NAME@"
#cmakedefine PACKAGE_VERSION "@PACKAGE_VERSION@"
#cmakedefine PACKAGE_STRING "@PACKAGE_STRING@"
#cmakedefine PACKAGE_TARNAME "@PACKAGE_TARNAME@"
#cmakedefine PACKAGE_BUGREPORT "@PACKAGE_BUGREPORT@"
#cmakedefine PACKAGE_URL "@PACKAGE_URL@"
#cmakedefine VERSION "@VERSION@"
#cmakedefine HAVE_ASSERT_H
#cmakedefine HAVE_CTYPE_H
#cmakedefine HAVE_DLFCN_H
#cmakedefine HAVE_FILE_H
#cmakedefine HAVE_INTTYPES_H
#cmakedefine HAVE_MATH_H
#cmakedefine HAVE_MEMORY_H
#cmakedefine HAVE_STDINT_H
#cmakedefine HAVE_STDIO_H
#cmakedefine HAVE_STDLIB_H
#cmakedefine HAVE_STRINGS_H
#cmakedefine HAVE_STRING_H
#cmakedefine HAVE_SYS_STAT_H
#cmakedefine HAVE_SYS_TYPES_H
#cmakedefine HAVE_UNISTD_H
############################################################################
# CMakeLists.txt
# Copyright (C) 2014 Belledonne Communications, Grenoble France
#
############################################################################
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
#
############################################################################
set(DOC_FILES
CUnit_doc.css
error_handling.html
fdl.html
index.html
introduction.html
managing_tests.html
running_tests.html
test_registry.html
writing_tests.html
)
install(FILES ${DOC_FILES}
DESTINATION doc/CUnit
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
file(GLOB HEADER_FILES "../CUnit/Headers/*.h")
list(APPEND HEADER_FILES "../CUnit/Sources/Win/Win.h")
install(FILES ${HEADER_FILES}
DESTINATION doc/CUnit/headers
PERMISSIONS OWNER_READ OWNER_WRITE GROUP_READ WORLD_READ
)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment