forked from hakimel/reveal.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Chapter 1 Lab
David Zemon edited this page Jul 18, 2018
·
8 revisions
We're going to add a third library to the project which will be an alternative to upper. The code for
useful will switch between using upper and this new library based on a preprocessor definition (#ifdef). We'll
also take the time to refactor our growing project's build system into smaller and more modular pieces.
- Read about the
add_subdirectory(...)command and segregate the relevant CMake scripting code into separateCMakeLists.txtfiles, one in each of the project's subdirectories.- This is also an opportune time to create a new directory for the main executable, containing
main.cppand its ownCMakeLists.txtfile. - Global code, such as the invocation of the
project()command, can and should be left in the primaryCMakeLists.txtscript at the root of the project.
- This is also an opportune time to create a new directory for the main executable, containing
- Create a new library (in a new child directory) named
lower, containing a single source file and an appropriate header in the commonincludedirectory. - Implement a
to_lower(...)function, similar toupper'sto_upper(...)function. - Using CMake, set a preprocessor definition,
LOWER, on thelowerlibrary such that any dependent targets ofloweralso inherit that definition. - Use the same CMake/preprocessor technique to define an
UPPERdefinition on theupperlibrary and its dependents - Add a CMake option that allows the user to easily switch between three different implementations for
useless:- Original case:
uselessis dependent on neitheruppernorlower. - Uppercase:
uselessis dependent onupper. - Lowercase:
uselessis dependent onlower.
- Original case:
- Utilize the preprocessor definition(s) set above in the
uselesscode to switch between the three implementations. - Run your code with all three options to ensure it works as expected. You may also wish to check your dependency diagrams as generated by Graphviz.