Skip to content

Commit

Permalink
Use target_include_directories (#598)
Browse files Browse the repository at this point in the history
* Use target_include_directories to specify include dirs
  • Loading branch information
RainerKuemmerle authored Aug 28, 2022
1 parent 26f775d commit 5575db9
Show file tree
Hide file tree
Showing 6 changed files with 90 additions and 66 deletions.
3 changes: 0 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -490,9 +490,6 @@ else()
include_directories(${EIGEN3_INCLUDE_DIR})
endif ()

# Set up the top-level include directories
include_directories(${g2o_SOURCE_DIR} ${PROJECT_BINARY_DIR})

# Generate config.h
set(G2O_OPENGL_FOUND ${OPENGL_FOUND})
set(G2O_HAVE_CHOLMOD ${CHOLMOD_FOUND})
Expand Down
4 changes: 4 additions & 0 deletions g2o/EXTERNAL/freeglut/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@ add_library(freeglut_minimal ${G2O_LIB_TYPE}
)

target_link_libraries(freeglut_minimal PUBLIC ${G2O_OPENGL_TARGET})
target_include_directories(freeglut_minimal PUBLIC
"$<BUILD_INTERFACE:${g2o_SOURCE_DIR};${PROJECT_BINARY_DIR}>"
$<INSTALL_INTERFACE:include/g2o/freeglut_minimal>
)

set_target_properties(freeglut_minimal PROPERTIES OUTPUT_NAME ${LIB_PREFIX}ext_freeglut_minimal)
if (APPLE)
Expand Down
129 changes: 66 additions & 63 deletions g2o/EXTERNAL/freeglut/freeglut_minimal.h
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#ifndef __FREEGLUT_EXT_H__
#define __FREEGLUT_EXT_H__
#ifndef __FREEGLUT_EXT_H__
#define __FREEGLUT_EXT_H__

/*
* freeglut_ext.h
Expand Down Expand Up @@ -28,79 +28,82 @@
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/

#include "g2o/stuff/opengl_wrapper.h"
#include "g2o/config.h"

#ifdef WINDOWS
#include <windows.h>
#endif

#ifdef __APPLE__
#include <OpenGL/gl.h>
#else
#include <GL/gl.h>
#endif

#ifdef _MSC_VER
// We are using a Microsoft compiler:
#ifdef G2O_SHARED_LIBS
# ifdef freeglut_minimal_EXPORTS
# define G2O_FGAPI __declspec(dllexport)
# else
# define G2O_FGAPI __declspec(dllimport)
# endif
#ifdef freeglut_minimal_EXPORTS
#define G2O_FGAPI __declspec(dllexport)
#else
# define G2O_FGAPI
#define G2O_FGAPI __declspec(dllimport)
#endif
#else
#define G2O_FGAPI
#endif
#else
// Not Microsoft compiler so set empty definition:
# define G2O_FGAPI
#define G2O_FGAPI
#endif

namespace freeglut_minimal {

enum FontID {
GLUT_STROKE_ROMAN,
GLUT_STROKE_MONO_ROMAN
};

/* The stroke font structures */

typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
struct tagSFG_StrokeVertex
{
GLfloat X, Y;
};

typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
struct tagSFG_StrokeStrip
{
int Number;
const SFG_StrokeVertex* Vertices;
};

typedef struct tagSFG_StrokeChar SFG_StrokeChar;
struct tagSFG_StrokeChar
{
GLfloat Right;
int Number;
const SFG_StrokeStrip* Strips;
};

typedef struct tagSFG_StrokeFont SFG_StrokeFont;
struct tagSFG_StrokeFont
{
char* Name; /* The source font name */
int Quantity; /* Number of chars in font */
GLfloat Height; /* Height of the characters */
const SFG_StrokeChar** Characters; /* The characters mapping */
};

extern const SFG_StrokeFont fgStrokeRoman;
extern const SFG_StrokeFont fgStrokeMonoRoman;

G2O_FGAPI void glutStrokeString(FontID font, const char* string);

/*
* Font stuff, see freeglut_font.c
*/
G2O_FGAPI GLfloat glutStrokeHeight(FontID font);

/*
* Return the width of a string drawn using a stroke font
*/
G2O_FGAPI int glutStrokeLength(FontID fontID, const char* string);

} // end namespace
enum FontID { GLUT_STROKE_ROMAN, GLUT_STROKE_MONO_ROMAN };

/* The stroke font structures */

typedef struct tagSFG_StrokeVertex SFG_StrokeVertex;
struct tagSFG_StrokeVertex {
GLfloat X, Y;
};

typedef struct tagSFG_StrokeStrip SFG_StrokeStrip;
struct tagSFG_StrokeStrip {
int Number;
const SFG_StrokeVertex* Vertices;
};

typedef struct tagSFG_StrokeChar SFG_StrokeChar;
struct tagSFG_StrokeChar {
GLfloat Right;
int Number;
const SFG_StrokeStrip* Strips;
};

typedef struct tagSFG_StrokeFont SFG_StrokeFont;
struct tagSFG_StrokeFont {
char* Name; /* The source font name */
int Quantity; /* Number of chars in font */
GLfloat Height; /* Height of the characters */
const SFG_StrokeChar** Characters; /* The characters mapping */
};

extern const SFG_StrokeFont fgStrokeRoman;
extern const SFG_StrokeFont fgStrokeMonoRoman;

G2O_FGAPI void glutStrokeString(FontID font, const char* string);

/*
* Font stuff, see freeglut_font.c
*/
G2O_FGAPI GLfloat glutStrokeHeight(FontID font);

/*
* Return the width of a string drawn using a stroke font
*/
G2O_FGAPI int glutStrokeLength(FontID fontID, const char* string);

} // namespace freeglut_minimal

/*** END OF FILE ***/

Expand Down
5 changes: 5 additions & 0 deletions g2o/core/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,11 @@ io_helper.h
g2o_core_api.h
)

target_include_directories(core PUBLIC
"$<BUILD_INTERFACE:${g2o_SOURCE_DIR};${PROJECT_BINARY_DIR}>"
$<INSTALL_INTERFACE:include/g2o/core>
)

set_target_properties(core PROPERTIES OUTPUT_NAME ${LIB_PREFIX}core)
target_link_libraries(core PUBLIC stuff ${G2O_EIGEN3_EIGEN_TARGET})
if(G2O_USE_VENDORED_CERES)
Expand Down
5 changes: 5 additions & 0 deletions g2o/solvers/eigen/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ if (APPLE)
endif()
target_link_libraries(solver_eigen core)

target_include_directories(solver_eigen PUBLIC
"$<BUILD_INTERFACE:${g2o_SOURCE_DIR};${PROJECT_BINARY_DIR}>"
$<INSTALL_INTERFACE:include/g2o/solver_eigen>
)

install(TARGETS solver_eigen
EXPORT ${G2O_TARGETS_EXPORT_NAME}
RUNTIME DESTINATION ${RUNTIME_DESTINATION}
Expand Down
10 changes: 10 additions & 0 deletions g2o/stuff/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ add_library(stuff ${G2O_LIB_TYPE}
g2o_stuff_api.h
)

target_include_directories(stuff PUBLIC
"$<BUILD_INTERFACE:${g2o_SOURCE_DIR};${PROJECT_BINARY_DIR}>"
$<INSTALL_INTERFACE:include/g2o/stuff>
)

set_target_properties(stuff PROPERTIES OUTPUT_NAME ${LIB_PREFIX}stuff)
target_link_libraries(stuff PUBLIC ${G2O_EIGEN3_EIGEN_TARGET})

Expand Down Expand Up @@ -42,6 +47,11 @@ if(OPENGL_FOUND AND G2O_HAVE_OPENGL)
INCLUDES DESTINATION ${INCLUDES_DESTINATION}
)

target_include_directories(opengl_helper PUBLIC
"$<BUILD_INTERFACE:${g2o_SOURCE_DIR};${PROJECT_BINARY_DIR}>"
$<INSTALL_INTERFACE:include/g2o/stuff>
)

target_link_libraries(opengl_helper PUBLIC ${G2O_OPENGL_TARGET} ${G2O_EIGEN3_EIGEN_TARGET})
set_target_properties(opengl_helper PROPERTIES OUTPUT_NAME "${LIB_PREFIX}opengl_helper")
endif()
Expand Down

0 comments on commit 5575db9

Please sign in to comment.