View Issue Details

IDProjectCategoryView StatusLast Update
0015712ScribusBuild Systempublic2019-07-16 12:34
Reporterale Assigned To 
PrioritynormalSeverityminorReproducibilityhave not tried
Status newResolutionopen 
Product Version1.5.5.svn 
Summary0015712: CMake: document how to create tools or library that are in their own directory
Descriptionas previously discussed, i'm trying to recreate the higher level API without making it a plugin, but still putting it in its own directory.

the goal is to create a directory with its own CMakeLists.txt file.

i've based the code on the text/ directory and while it compiles and links without any error, at run time i get a "symbol missing" error for the class functions that have their body defined in the .cpp files.

for the API, these are the modifications i've made to the CMakeLists.txt in the scribus/ directory:

diff --git a/scribus/CMakeLists.txt b/scribus/CMakeLists.txt
index 76c73e3db..ca2e66242 100644
--- a/scribus/CMakeLists.txt
+++ b/scribus/CMakeLists.txt
@@ -30,6 +30,7 @@ add_subdirectory(desaxe)
@@ -1105,6 +1109,7 @@ link_directories(
@@ -1127,6 +1132,7 @@ endif ()

 set(SCRIBUS_COLORMGMT_LIB "scribus_colormgmt_lib")
 set(SCRIBUS_TEXT_LIB "scribus_text_lib")
+set(SCRIBUS_API_LIB "scribus_api_lib")
        set(SCRIBUS_TESTS_LIB "scribus_tests_lib")
@@ -1209,6 +1215,7 @@ if(HAVE_OSG)
@@ -1224,6 +1231,7 @@ else()
@@ -1332,6 +1340,7 @@ target_link_libraries(${EXE_NAME}

it is to be noted that the part in the IF(OSG) ... ELSE() is probably not needed (most of the entries in there are undefined)...

the CMakeLists.txt file in the api/ directory is:

    ${FREETYPE_INCLUDE_DIRS} # we need those if we want to scribusdoc





set(SCRIBUS_API_LIB "scribus_api_lib")


# This is a convenience library that for linkage purposes is part of Scribus's
# main API.

it would be wonderful to have a documentation that states what is needed for adding a new directory in scribus code for both cases:

- include the code in the exe itself. (this is what i think the code above should achieve...)
- create a .so / .dll.
TagsNo tags attached.


related to 0015739 new Metabug: improve code modularity 



2019-06-14 07:32

manager   ~0046303

of course, if i add the .cpp files in the scribus/CMakeLists.txt's SCRIBUS_SOURCES then it works... but i'd really like to touch as little as possible in the files that are outside "my" directory.

for the plugins this works perfectly: it's just one more entry in the parent directory's CMakeLists.txt ...

... the goal being that i can keep a "clean" master and that i can easily share my test code with other people (without having to explain all the things they have to change in the scribus code)


2019-06-26 13:27

manager   ~0046342

i got it, i think!

a good example is how the zip library gets added.

in the scribus/CMakeLists.txt one needs to add

- the directory with `add_subdirectory(newdirectory)`
- the directory to `link_directories()` as `${CMAKE_CURRENT_BINARY_DIR}/newdirectory`
- the string of the "library" as defined in the library's CMakeLists.txt: `set(SCRIBUS_NEWDIRECTORY_LIB "scribus_newdirectory_lib")`
- link the ${SCRIBUS_NEWDIRECOTRY_LIB} library code in `target_link_libraries(${EXE_NAME} (...)`

the library's CMakeLists.txt file will look like this:



    # xxx.h

    # xxx.cpp


set(SCRIBUS_NEWDIRECTORY_LIB "scribus_newdirectory_lib")


Issue History

Date Modified Username Field Change
2019-06-13 19:48 ale New Issue
2019-06-14 07:32 ale Note Added: 0046303
2019-06-26 13:27 ale Note Added: 0046342
2019-07-16 12:33 ale Relationship added related to 0015739
2019-07-16 12:34 ale Summary document how to create tools or library that are in their own directory => CMake: document how to create tools or library that are in their own directory