Unit Test Framework for non-boost projects?
I believe I figured out how the examples in the 'subproject libs/test/example ;' are being compiled. Basically it goes like this: bjam reads the Jamfile which contains this rule: rule boost-test-example ( example-name : lib-name ) { exe $(example-name) : $(example-name).cpp <lib>../build/$(lib-name) : <sysinclude>$(BOOST_ROOT) <stlport-iostream>on <borland><*><cxxflags>-w-8080 ; } followed by a series of invocation of that rule such as: boost-test-example unit_test_example1 : boost_unit_test_framework ; The rule is evaluated by putting the first argument 'unit_test_example1' in the slot for the target name, and for the sources required to build. In addition to unit_test_example1.cpp, the expression <lib>../build/$(lib-name) is evaluated to add the library resulting from compiling other source files. These are named by reading $(BOOST_ROOT)/libs/test/build/Jamfile and expanding the target: lib boost_unit_test_framework : <template>boost_test_lib ../src/$(UTF_SOURCES).cpp ; The <template> adds some boiler-plate information and the ../src/$(UTF_SOURCES).cpp expands the following list: UTF_SOURCES = execution_monitor test_tools unit_test_parameters unit_test_log unit_test_monitor unit_test_result unit_test_suite unit_test_main supplied_log_formatters ; to create a list of file names of the form: ../src/execution_monitor.cpp If the library does not already exists, these are compiled, and the results are placed in the location specified by this directive: install test lib : [ unless $(NT) : <dll>boost_prg_exec_monitor <dll>boost_test_exec_monitor <dll>boost_unit_test_framework ] <lib>boost_prg_exec_monitor <lib>boost_test_exec_monitor <lib>boost_unit_test_framework ; Since they have already been compiled, bjam tells the compiler to link against them. After rebuilding all of boost and installing the headers and libraries to the default location, I am now able to compile one of the examples as follows: g++ -o unit_test_example5 unit_test_example5.cpp\ -lboost_unit_test_framework-gcc I don't fully understand why I need the -l switch, but adding it enabled the linker to succeed. I assume I could find a way to modify the above mentioned Jamfiles to do basically the same thing in my project directory, but the step of specifying the sources with which to build the libraries seems inappropriate for using the Unit Test Framework in my own project. How do I tell bjam to link against the correct library file? -- Regards, Steven
participants (2)
-
Gennadiy Rozental
-
Steven T. Hatton