ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

This happened because I was overwriting the CMAKE_CXX_FLAGS flag in my CMakeLists.txt:

Old CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
set (CMAKE_CXX_FLAGS "-fPIC")
project(bezier_library)

The good way of doing this is using the CMake set_property command, new CMakeLists.txt

add_library (bezier_library_obj OBJECT src/bezier_library.cpp)
set_property(TARGET bezier_library_obj APPEND_STRING PROPERTY COMPILE_FLAGS "-fPIC -Wall")
add_library (${PROJECT_NAME} $<TARGET_OBJECTS:bezier_library_obj>)

This happened because I was overwriting the CMAKE_CXX_FLAGS flag in my CMakeLists.txt:

Old CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
set (CMAKE_CXX_FLAGS "-fPIC")
project(bezier_library)

The good way of doing this is using the CMake set_property command, new CMakeLists.txt

add_library (bezier_library_obj OBJECT src/bezier_library.cpp)
set_property(TARGET bezier_library_obj APPEND_STRING PROPERTY COMPILE_FLAGS "-fPIC -Wall")
add_library (${PROJECT_NAME} $<TARGET_OBJECTS:bezier_library_obj>)

This happened because I was overwriting the CMAKE_CXX_FLAGS flag in my CMakeLists.txt:

Old CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
set (CMAKE_CXX_FLAGS "-fPIC")
project(bezier_library)

The good right way of doing to do this is using to use the CMake set_property command, new CMakeLists.txt

add_library (bezier_library_obj OBJECT src/bezier_library.cpp)
set_property(TARGET bezier_library_obj APPEND_STRING PROPERTY COMPILE_FLAGS "-fPIC -Wall")
add_library (${PROJECT_NAME} $<TARGET_OBJECTS:bezier_library_obj>)

This happened because I was overwriting the CMAKE_CXX_FLAGS flag in my CMakeLists.txt:

Old CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
set (CMAKE_CXX_FLAGS "-fPIC")
project(bezier_library)

Add compile options:

add_compile_options("-fPIC")

This is the old, deprecated way of doing it

The right way to do this is to use the CMake set_property command, new CMakeLists.txt

add_library (bezier_library_obj OBJECT src/bezier_library.cpp)
set_property(TARGET bezier_library_obj APPEND_STRING PROPERTY COMPILE_FLAGS "-fPIC -Wall")
add_library (${PROJECT_NAME} $<TARGET_OBJECTS:bezier_library_obj>)

This happened because I was overwriting the CMAKE_CXX_FLAGS flag in my CMakeLists.txt:

Old CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
set (CMAKE_CXX_FLAGS "-fPIC")
project(bezier_library)

Add compile options:Instead of set, use add_compile_options:

add_compile_options("-fPIC")

This is the old, deprecated way of doing it

The right way to do this is to use the CMake set_property command, new CMakeLists.txt

add_library (bezier_library_obj OBJECT src/bezier_library.cpp)
set_property(TARGET bezier_library_obj APPEND_STRING PROPERTY COMPILE_FLAGS "-fPIC -Wall")
add_library (${PROJECT_NAME} $<TARGET_OBJECTS:bezier_library_obj>)

This happened because I was overwriting the CMAKE_CXX_FLAGS flag in my CMakeLists.txt:

Old CMakeLists.txt

cmake_minimum_required(VERSION 2.8.3)
set (CMAKE_CXX_FLAGS "-fPIC")
project(bezier_library)

Instead of set, use add_compile_options:

add_compile_options("-fPIC")

This is the old, deprecated way of doing it

The right way to do this is to use the CMake set_property command, new CMakeLists.txt

add_library (bezier_library_obj OBJECT src/bezier_library.cpp)
set_property(TARGET bezier_library_obj APPEND_STRING PROPERTY COMPILE_FLAGS "-fPIC -Wall")
add_library (${PROJECT_NAME} $<TARGET_OBJECTS:bezier_library_obj>)