Skip to content

Commit 2a2f912

Browse files
fanc999-1kjellahl
authored andcommitted
build: Build the examples and tests on MSVC builds
Also add a BOOST_DLL option for one to build the benchmark program for libsigc++, which is needed on Visual Studio builds if the installed Boost libraries are built as DLLs.
1 parent 0cc1962 commit 2a2f912

File tree

6 files changed

+69
-11
lines changed

6 files changed

+69
-11
lines changed

MSVC_NMake/Makefile.vc

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,15 @@ VALID_MSC = TRUE
3434
# into the lists we need for compilation and introspection
3535
!include create-lists-msvc.mak
3636

37-
all: $(LIBSIGC_LIB) all-build-info
37+
all: $(LIBSIGC_LIB) $(libsigc_ex) all-build-info
3838

39-
tests: all
39+
tests: $(libsigc_tests) all-build-info
40+
41+
benchmark: all $(libsigc_bench) all-build-info
4042

4143
# Include the build rules for sources, DLLs and executables
42-
!include build-rules-msvc.mak
4344
!include generate-msvc.mak
45+
!include build-rules-msvc.mak
4446

4547
!include install.mak
4648

MSVC_NMake/build-rules-msvc.mak

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@ $<
2323
$<
2424
<<
2525

26+
$(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj: $(CFG)\$(PLAT)\libsigcpp-tests ..\tests\testutilities.cc
27+
$(CXX) $(SIGCPP_CFLAGS) /Fo$@ /c ..\tests\testutilities.cc
2628
# Rules for building .lib files
2729
$(LIBSIGC_LIB): $(LIBSIGC_DLL)
2830

@@ -50,17 +52,36 @@ $(libsigcpp_dll_OBJS)
5052
# <<
5153
# @-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
5254

53-
$(CFG)\$(PLAT)\gjs-console.exe: $(CFG)\$(PLAT)\gjs.lib $(CFG)\$(PLAT)\gjs-console $(gjs_OBJS)
54-
link $(LDFLAGS) $(CFG)\$(PLAT)\gjs.lib $(GJS_BASE_LIBS) -out:$@ $(gjs_OBJS)
55+
{..\examples\}.cc{$(CFG)\$(PLAT)\}.exe:
56+
@if not exist $(CFG)\$(PLAT)\libsigcpp-ex $(MAKE) -f Makefile.vc CFG=$(CFG) $(CFG)\$(PLAT)\libsigcpp-ex
57+
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
58+
$(CXX) $(SIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp-ex\ $< /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB)
59+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
60+
61+
{..\tests\}.cc{$(CFG)\$(PLAT)\}.exe:
62+
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
63+
@if not exist $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj $(MAKE) -f Makefile.vc CFG=$(CFG) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
64+
$(CXX) $(SIGCPP_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp-tests\ $< /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
65+
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
66+
67+
$(CFG)\$(PLAT)\libsigc++-benchmark.exe: ..\tests\benchmark.cc
68+
@if not exist $(LIBSIGC_LIB) $(MAKE) -f Makefile.vc CFG=$(CFG) $(LIBSIGC_LIB)
69+
@if not exist $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj $(MAKE) -f Makefile.vc CFG=$(CFG) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
70+
$(CXX) $(SIGCPP_BENCHMARK_CFLAGS) /Fo$(CFG)\$(PLAT)\libsigcpp-tests\ ..\tests\benchmark.cc /Fe$@ /link $(LDFLAGS) $(LIBSIGC_LIB) $(CFG)\$(PLAT)\libsigcpp-tests\testutilities.obj
5571
@-if exist $@.manifest mt /manifest $@.manifest /outputresource:$@;1
5672

5773
clean:
58-
@-del /f /q $(CFG)\$(PLAT)\*.pdb
74+
@-del /f /q $(CFG)\$(PLAT)\*.exe
5975
@-del /f /q $(CFG)\$(PLAT)\*.dll
76+
@-del /f /q $(CFG)\$(PLAT)\*.pdb
6077
@-del /f /q $(CFG)\$(PLAT)\*.ilk
6178
@-del /f /q $(CFG)\$(PLAT)\*.exp
6279
@-del /f /q $(CFG)\$(PLAT)\*.lib
80+
@-if exist $(CFG)\$(PLAT)\libsigcpp-tests del /f /q $(CFG)\$(PLAT)\libsigcpp-tests\*.obj
81+
@-del /f /q $(CFG)\$(PLAT)\libsigcpp-ex\*.obj
6382
@-del /f /q $(CFG)\$(PLAT)\libsigcpp\*.res
6483
@-del /f /q $(CFG)\$(PLAT)\libsigcpp\*.obj
84+
@-if exist $(CFG)\$(PLAT)\libsigcpp-tests rd $(CFG)\$(PLAT)\libsigcpp-tests
85+
@-rd $(CFG)\$(PLAT)\libsigcpp-ex
6586
@-rd $(CFG)\$(PLAT)\libsigcpp
6687
@-del /f /q vc$(PDBVER)0.pdb

MSVC_NMake/config-msvc.mak

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LIBSIGC_DEBUG_SUFFIX =
1616

1717
LIBSIGCPP_DEFINES = /DSIGC_BUILD /D_WINDLL
1818

19-
SIGCPP_BASE_CFLAGS = /I.. /I. /wd4530 /std:c++17
19+
SIGCPP_BASE_CFLAGS = /I.. /I. /wd4530 /std:c++17 $(CFLAGS)
2020

2121
LIBSIGC_INT_SOURCES = $(sigc_sources_cc:/=\)
2222
LIBSIGC_INT_HDRS = $(sigc_public_h:/=\)
@@ -31,3 +31,13 @@ LIBSIGC_LIBNAME = sigc-vc$(VSVER)0$(LIBSIGC_DEBUG_SUFFIX)-$(LIBSIGC_MAJOR_VERSIO
3131

3232
LIBSIGC_DLL = $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).dll
3333
LIBSIGC_LIB = $(CFG)\$(PLAT)\$(LIBSIGC_LIBNAME).lib
34+
35+
# Note that building the benchmark requires Boost!
36+
libsigc_bench = $(CFG)\$(PLAT)\libsigc++-benchmark.exe
37+
38+
# If your Boost libraries are built as DLLs, use BOOST_DLL=1 in your NMake command line
39+
!ifdef BOOST_DLL
40+
SIGCPP_BENCHMARK_CFLAGS = $(SIGCPP_BASE_CFLAGS) /DBOOST_ALL_DYN_LINK
41+
!else
42+
SIGCPP_BENCHMARK_CFLAGS = $(SIGCPP_BASE_CFLAGS)
43+
!endif

MSVC_NMake/create-lists-msvc.mak

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,26 @@ NULL=
4747
!if [call create-lists.bat footer libsigcpp.mak]
4848
!endif
4949

50+
!if [call create-lists.bat header libsigcpp.mak libsigc_ex]
51+
!endif
52+
53+
!if [for %s in (..\examples\*.cc) do @call create-lists.bat file libsigcpp.mak ^$(CFG)\^$(PLAT)\%~ns.exe]
54+
!endif
55+
56+
!if [call create-lists.bat footer libsigcpp.mak]
57+
!endif
58+
59+
!if [call create-lists.bat header libsigcpp.mak libsigc_tests]
60+
!endif
61+
62+
# Skipping testutilities.cc: Not to be built as a .exe, but is a common dependency for the tests
63+
# benchmark: Not built on default; requires Boost
64+
!if [for %s in (..\tests\*.cc) do @if not "%~ns" == "testutilities" if not "%~ns" == "benchmark" @call create-lists.bat file libsigcpp.mak ^$(CFG)\^$(PLAT)\%~ns.exe]
65+
!endif
66+
67+
!if [call create-lists.bat footer libsigcpp.mak]
68+
!endif
69+
5070
!include libsigcpp.mak
5171

5272
!if [del /f /q libsigcpp.mak]

MSVC_NMake/generate-msvc.mak

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@
44
# one is maintaining the NMake build files.
55

66
# Create the build directories
7-
$(CFG)\$(PLAT)\libsigcpp:
7+
$(CFG)\$(PLAT)\libsigcpp $(CFG)\$(PLAT)\libsigcpp-ex $(CFG)\$(PLAT)\libsigcpp-tests:
88
@-mkdir $@

MSVC_NMake/info-msvc.mak

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,13 @@ help:
2828
@echo A 'clean' target is supported to remove all generated files, intermediate
2929
@echo object files and binaries for the specified configuration.
3030
@echo.
31-
@echo An 'install' target is supported to copy the build (DLLs, utility programs,
32-
@echo LIBs, along with the introspection files if applicable) to appropriate
33-
@echo locations under ^$(PREFIX).
31+
@echo An 'install' target is supported to copy the build (DLLs, LIBs, along with
32+
@echo the header files) to appropriate locations under ^$(PREFIX).
33+
@echo.
34+
@echo A 'tests' target is supported to build the test programs, and a 'benchmark'
35+
@echo target is supported to build the benchmarking program. Note that the
36+
@echo benchmarking program requires the Boost C++ libraries to build, and you need
37+
@echo to pass in BOOST_DLL=1 to the NMake command line if your Boost libraries are
38+
@echo built as DLLs.
3439
@echo ======
3540
@echo.

0 commit comments

Comments
 (0)