bugThe FreeType Project - Bugs: bug #53816, Make target_include_directories...

 
 

You are not allowed to post comments on this tracker with your current authentication level.

bug #53816: Make target_include_directories PUBLIC

Submitter:  Steve Robinson <ssrobins>
Submitted:  Thu 03 May 2018 01:38:08 AM UTC
   
 
Severity:  3 - Normal Item Group:  None
Status:  Fixed Privacy:  Public
Assigned to:  morksig Open/Closed:  Closed
Planned Release:  None

Jump to the original submission

Tue 08 May 2018 05:15:21 AM UTC, comment #6: 

I added your edited CMakeLists.txt file into my build system and freetype built fine on Windows, Linux, and Mac.  Thanks for working on that :)

find_package only works like magic if you have the library already built.  For small libraries, I prefer to untar the source, use the add_subdirectory command to add it into my project and directly use all the CMake target information to build my program.  That way, it's really easy to upgrade and build on many platforms, but the library isn't mixed in with my project source.

I suppose I could use Conan Package manager, but last I checked there weren't many libraries officially supported and I haven't had the time to help out.

Steve Robinson <ssrobins>
Mon 07 May 2018 10:13:22 PM UTC, comment #5: 

Actually, can you try https://github.com/madig/freetype2/tree/cmake-fix-project-inclusion and see if it does what you need?

>  I statically link to freetype so I don't think library exports would help me

What I mean is something like

find_package(FreeType 2.9.1 REQUIRED)
target_link_libraries(example FreeType::FreeType)


and it just magically works, as described in https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/.

Nikolaus Waxweiler <morksig>
Group Member
Fri 04 May 2018 12:17:46 AM UTC, comment #4: 

I guess I don't need it personally because I'm extracting the freetype source tar and building in the CMAKE_CURRENT_BINARY_DIR, but if those are public headers, then others will.  More details on my build setup here:
https://savannah.nongnu.org/bugs/index.php?53815

I'm using the latest version of CMake.  I statically link to freetype so I don't think library exports would help me, but I bet others would appreciate it.

Steve Robinson <ssrobins>
Thu 03 May 2018 11:45:06 AM UTC, comment #3: 

Uh... I suppose you'd need

    target_include_directories(
      freetype BEFORE  # Pick up ftconfig.h and ftoption.h generated above.
        PRIVATE "${PROJECT_BINARY_DIR}/include")

PUBLIC, too?

Which CMake version are you using? I was thinking about putting in optional modern library exports like explained in https://www.youtube.com/watch?v=bsXLMQ6WgIk and https://pabloariasal.github.io/2018/02/19/its-time-to-do-cmake-right/.

Nikolaus Waxweiler <morksig>
Group Member
Thu 03 May 2018 04:51:01 AM UTC, comment #2: 

I've fixed the title and assigned it to Nikolaus.

Werner LEMBERG <wl>
Group administrator
Thu 03 May 2018 01:39:44 AM UTC, comment #1: 

Sorry I somehow screwed up the bug title.  It should be, "Make target_include_directories PUBLIC"

Steve Robinson <ssrobins>
Thu 03 May 2018 01:38:08 AM UTC, original submission:  

In Freetype 2.9.1, CMakeLists.txt has code to privately set the include directory:
target_include_directories(
  freetype
    PRIVATE "${PROJECT_SOURCE_DIR}/include")

I recommend changing it to public:
target_include_directories(
  freetype
    PUBLIC "${PROJECT_SOURCE_DIR}/include")

That way, all users have to do is add the freetype subdirectory in CMake and add freetype to the target_link_libraries for the library/executable that depends on it.  No need to duplicate the include definition in the user's build code.  If at some point, you decide to change the include path, you change it in the freetype CMake and it automatically updates in user's code.

Steve Robinson <ssrobins>

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -email is unavailable- added by morksig (Posted a comment)
  • -email is unavailable- added by wl (Posted a comment)
  • -email is unavailable- added by ssrobins (Submitted the item)
  •  

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

     

    Follow 4 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2018-05-09 morksig StatusNone Fixed
        Open/ClosedOpen Closed
    2018-05-03 wl Assigned toNone morksig
        SummaryMake Make target_include_directories PUBLIC

    Back to the top

    Powered by Savane 3.13-bb6a.
    Corresponding source code