1 # add the library that runs
2 add_library(MathFunctions MathFunctions.cxx)
4 # state that anybody linking to us needs to include the current source dir
5 # to find MathFunctions.h, while we don't.
6 target_include_directories(MathFunctions
7 INTERFACE ${CMAKE_CURRENT_SOURCE_DIR}
10 # should we use our own math functions
11 option(USE_MYMATH "Use tutorial provided math implementation" ON)
14 target_compile_definitions(MathFunctions PRIVATE "USE_MYMATH")
16 # first we add the executable that generates the table
17 add_executable(MakeTable MakeTable.cxx)
19 # add the command to generate the source code
21 OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/Table.h
22 COMMAND MakeTable ${CMAKE_CURRENT_BINARY_DIR}/Table.h
26 # library that just does sqrt
27 add_library(SqrtLibrary STATIC
29 ${CMAKE_CURRENT_BINARY_DIR}/Table.h
32 # state that we depend on our binary dir to find Table.h
33 target_include_directories(SqrtLibrary PRIVATE
34 ${CMAKE_CURRENT_BINARY_DIR}
37 # state that SqrtLibrary need PIC when the default is shared libraries
38 set_target_properties(SqrtLibrary PROPERTIES
39 POSITION_INDEPENDENT_CODE ${BUILD_SHARED_LIBS}
42 target_link_libraries(MathFunctions PRIVATE SqrtLibrary)
45 # define the symbol stating we are using the declspec(dllexport) when
47 target_compile_definitions(MathFunctions PRIVATE "EXPORTING_MYMATH")
50 set(installable_libs MathFunctions)
51 if(TARGET SqrtLibrary)
52 list(APPEND installable_libs SqrtLibrary)
54 install(TARGETS ${installable_libs} DESTINATION lib)
55 install(FILES MathFunctions.h DESTINATION include)