[cmake-commits] david.cole committed CMakeLists.txt NONE 1.1 CTestConfig.cmake NONE 1.1 License.txt NONE 1.1 TutorialConfig.h.in NONE 1.1 build1.cmake NONE 1.1 build2.cmake NONE 1.1 tutorial.cxx NONE 1.1

cmake-commits at cmake.org cmake-commits at cmake.org
Thu Nov 8 10:38:28 EST 2007


Update of /cvsroot/CMake/CMake/Tests/Tutorial/Step7
In directory public:/mounts/ram/cvs-serv25735/Tutorial/Step7

Added Files:
	CMakeLists.txt CTestConfig.cmake License.txt 
	TutorialConfig.h.in build1.cmake build2.cmake tutorial.cxx 
Log Message:
ENH: Add new Tutorial steps. Diff between Step5 and Step6 shows how to add a cpack driven installer to your project. Diff between Step6 and Step7 shows how to add ctest dashboard scripting capability.


--- NEW FILE: CTestConfig.cmake ---
SET(CTEST_PROJECT_NAME "Tutorial")

--- NEW FILE: build1.cmake ---
SET(CTEST_SOURCE_DIRECTORY "$ENV{HOME}/Dashboards/My Tests/CMake/Tests/Tutorial/Step7")
SET(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-build1")

SET(CTEST_CMAKE_COMMAND "cmake")
SET(CTEST_COMMAND "ctest -D Experimental")

--- NEW FILE: TutorialConfig.h.in ---
// the configured options and settings for Tutorial
#define Tutorial_VERSION_MAJOR @Tutorial_VERSION_MAJOR@
#define Tutorial_VERSION_MINOR @Tutorial_VERSION_MINOR@
#cmakedefine USE_MYMATH

// does the platform provide exp and log functions?
#cmakedefine HAVE_LOG
#cmakedefine HAVE_EXP


--- NEW FILE: tutorial.cxx ---
// A simple program that computes the square root of a number
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include "TutorialConfig.h"

#ifdef USE_MYMATH
#include "MathFunctions.h"
#endif

int main (int argc, char *argv[])
{
  if (argc < 2)
    {
    fprintf(stdout,"%s Version %d.%d\n",
            argv[0],
            Tutorial_VERSION_MAJOR,
            Tutorial_VERSION_MINOR);
    fprintf(stdout,"Usage: %s number\n",argv[0]);
    return 1;
    }

  double inputValue = atof(argv[1]);

#ifdef USE_MYMATH
  double outputValue = mysqrt(inputValue);
#else
  double outputValue = sqrt(inputValue);
#endif

  fprintf(stdout,"The square root of %g is %g\n",
          inputValue, outputValue);
  return 0;
}

--- NEW FILE: CMakeLists.txt ---
project (Tutorial)

# The version number.
set (Tutorial_VERSION_MAJOR 1)
set (Tutorial_VERSION_MINOR 0)

# does this system provide the log and exp functions?
include (${CMAKE_ROOT}/Modules/CheckFunctionExists.cmake)
check_function_exists (log HAVE_LOG)
check_function_exists (exp HAVE_EXP)

# should we use our own math functions
option(USE_MYMATH "Use tutorial provided math implementation" ON)

# configure a header file to pass some of the CMake settings
# to the source code
configure_file (
  "${PROJECT_SOURCE_DIR}/TutorialConfig.h.in"
  "${PROJECT_BINARY_DIR}/TutorialConfig.h"
  )

# add the binary tree to the search path for include files
# so that we will find TutorialConfig.h
include_directories ("${PROJECT_BINARY_DIR}")

# add the MathFunctions library?
if (USE_MYMATH)
  include_directories ("${PROJECT_SOURCE_DIR}/MathFunctions")
  add_subdirectory (MathFunctions)
  set (EXTRA_LIBS ${EXTRA_LIBS} MathFunctions)
endif (USE_MYMATH)

# add the executable
add_executable (Tutorial tutorial.cxx)
target_link_libraries (Tutorial  ${EXTRA_LIBS})

# add the install targets
install_targets (/bin Tutorial)
install_files (/include FILES "${PROJECT_BINARY_DIR}/TutorialConfig.h")

# enable testing
enable_testing ()

# does the application run
add_test (TutorialRuns Tutorial 25)

# does the usage message work?
add_test (TutorialUsage Tutorial)
set_tests_properties (TutorialUsage
  PROPERTIES 
  PASS_REGULAR_EXPRESSION "Usage:.*number"
  )

#define a macro to simplify adding tests
macro (do_test arg result)
  add_test (TutorialComp${arg} Tutorial ${arg})
  set_tests_properties (TutorialComp${arg}
    PROPERTIES PASS_REGULAR_EXPRESSION ${result}
    )
endmacro (do_test)

# do a bunch of result based tests
do_test (4 "4 is 2")
do_test (9 "9 is 3")
do_test (5 "5 is 2.236")
do_test (7 "7 is 2.645")
do_test (25 "25 is 5")
do_test (-25 "-25 is 0")
do_test (0.0001 "0.0001 is 0.01")

# build a CPack driven installer package
include (InstallRequiredSystemLibraries)
SET(CPACK_RESOURCE_FILE_LICENSE "${CMAKE_CURRENT_SOURCE_DIR}/License.txt")
SET(CPACK_PACKAGE_VERSION_MAJOR "${Tutorial_VERSION_MAJOR}")
SET(CPACK_PACKAGE_VERSION_MINOR "${Tutorial_VERSION_MINOR}")
INCLUDE (CPack)

# enable dashboard scripting
INCLUDE (CTest)

--- NEW FILE: build2.cmake ---
SET(CTEST_SOURCE_DIRECTORY "$ENV{HOME}/Dashboards/My Tests/CMake/Tests/Tutorial/Step7")
SET(CTEST_BINARY_DIRECTORY "${CTEST_SOURCE_DIRECTORY}-build2")
SET(CTEST_CMAKE_GENERATOR "Visual Studio 8 2005")

CTEST_START("Experimental")
CTEST_CONFIGURE(BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_BUILD(BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_TEST(BUILD "${CTEST_BINARY_DIRECTORY}")
CTEST_SUBMIT()

--- NEW FILE: License.txt ---
This is the open source License.txt file introduced in
CMake/Tests/Tutorial/Step6...



More information about the Cmake-commits mailing list