CMake unrecognized -fpic and -fPIC flags
                    I'm getting a strange error with CMake.
/Users/blabla/libsimpletools/libsimpletools.c:1:0: error: -fPIC and -fpic are not supportedmakeCOLOR=#800000]2[/COLOR: *** [lib/CMakeFiles/simpletools.dir/parallax/Utility/libsimpletools/libsimpletools.c.o] Error 1makeCOLOR=#800000]1[/COLOR: *** [lib/CMakeFiles/simpletools.dir/all] Error 2make: *** [all] Error 2
This should call the propeller-elf-gcc-4.6.1 available in the path feeding all source files and libraries.
The compiler flags:
SET (CMAKE_C_FLAGS "-std=c99 -ltiny -lsimpletools -mcmm -fno-exceptions -mcog -lpthread -Os -o ${project_PROPELLER_SRCS} -cmm project.elf") Where the files are fetched with a FILE(GLOB_RECURSE).
What are -fpic and -fPIC? Couldn't find info anywhere.
                            /Users/blabla/libsimpletools/libsimpletools.c:1:0: error: -fPIC and -fpic are not supportedmakeCOLOR=#800000]2[/COLOR: *** [lib/CMakeFiles/simpletools.dir/parallax/Utility/libsimpletools/libsimpletools.c.o] Error 1makeCOLOR=#800000]1[/COLOR: *** [lib/CMakeFiles/simpletools.dir/all] Error 2make: *** [all] Error 2
This should call the propeller-elf-gcc-4.6.1 available in the path feeding all source files and libraries.
The compiler flags:
SET (CMAKE_C_FLAGS "-std=c99 -ltiny -lsimpletools -mcmm -fno-exceptions -mcog -lpthread -Os -o ${project_PROPELLER_SRCS} -cmm project.elf") Where the files are fetched with a FILE(GLOB_RECURSE).
What are -fpic and -fPIC? Couldn't find info anywhere.

 
                            
Comments
No one has tried to use make or cmake with Simple LIbraries before.
Typically the libraries are built with SimpleIDE.
I can see some utility in using make or cmake for creating the libraries.
Can you share your make file?
The idea was simple, have a few tasks e.g make clean make run make test.
CMAKE_MINIMUM_REQUIRED (VERSION 2.8)
PROJECT (test)
SET (test_VERSION_MAJOR 0)
SET (test_VERSION_MINOR 0)
SET (test_VERSION_PATCH 1)
SET (CMAKE_C_COMPILER propeller-elf-gcc-4.6.1)
SET (CMAKE_CROSSCOMPILING FALSE)
add_subdirectory (src)
add_subdirectory (lib)
file(GLOB test_SRCS src/*.c src/*.h)
file(GLOB test_PROPELLER_SRCS src/*.c src/*.elf src/*.spin src/*.side)
message("${test_PROPELLER_SRCS}")
SET (CMAKE_C_FLAGS "-std=c99 -ltiny -lsimpletools -mcmm -fno-exceptions -mcog -lpthread -Os -o test ${test_SRCS}") message("${CMAKE_C_FLAGS}")
add_executable(test ${test_SRCS})
target_link_libraries(test unity simpletools)
install (TARGETS test DESTINATION bin)
The problem is that CMake is passing some default flags to the propeller compiler, specifically -fpic -fPIC
You aren't doing it the right way to say enough. Now, unfortunately, I modified my working code recently so it is broken. I think I have a backup however that may have a working build system still.
Please PM me later to remind me. Thanks,
Perhaps you could override -fPIC and -fpic with -no-fpic ?
You can't use -mcmm and -mcog at the same time. Just use -mcmm.
I seriously recommend not using Tiny especially if you are using simpletools.
First you need a top level file, then some directory linkers, then the bottom level files that have code builders in them and some spec files. Finally you need a tool chain file.
You may need to patch some of the names of things and patches in the code below... but, in general the code works. It should take you about a day to get it working or less. Refer to the CMake Wiki for help.
File System Layout
binaries code |--CmakeList.txt (Top build file) |--ToolChain.cmake (Tool Chain File) |--libraries | |--CMakeList.txt (Directory Linker) | | | `--lib0 | |--source-list.cmake (Library Source File) | |--CMakeList.txt (Library Builder File) | `--lic.c | `--projects | |--CMakeList.txt (Directory Linker) | `project0 | |--CMakeList.txt (Project Builder) `--Source.cTop Build File
################################################################################ # @file # CMake Lists Main File # # @version @n 1.0 # @date @n 9/1/2012 # # @authors @n Kwabena W. Agyeman # @copyright @n (c) 2012 Kwabena W. Agyeman # @n All rights reserved - Please see the end of the file for the terms of use # # @par Update History: # @n v0.1 - Original release - 9/1/2012 ################################################################################ PROJECT(Propeller C CXX) CMAKE_MINIMUM_REQUIRED(VERSION 2.8) SET(CMAKE_BUILD_TYPE NONE) SET(CMAKE_INSTALL_PREFIX ../${CMAKE_SOURCE_DIR}) SET(CMAKE_BINARY_DIR ../binaries) SET(CMAKE_TOOLCHAIN_FILE Toolchain-P8X32A.cmake) ADD_SUBDIRECTORY("libraries") ADD_SUBDIRECTORY("projects") ################################################################################ # @file # @par MIT License - TERMS OF USE: # @n Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # @n # @n The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # @n # @n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. ################################################################################Tool Chain File
################################################################################ # @file # CMake P8X32A Toolchain File # # @version @n 1.0 # @date @n 9/9/2013 # # @author @n Kwabena W. Agyeman # @copyright @n (c) 2013 Kwabena W. Agyeman # @n All rights reserved - Please see the end of the file for the terms of use # # @par Update History: # @n v1.0 - Original release - 9/9/2013 ################################################################################ INCLUDE(CMakeForceCompiler) SET(CMAKE_SYSTEM_NAME Generic) SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_SYSTEM_PROCESSOR P8X32A) IF(UNIX) CMAKE_FORCE_C_COMPILER("../propgcc/bin/propeller-elf-gcc" GNU) CMAKE_FORCE_CXX_COMPILER("../propgcc/bin/propeller-elf-g++" GNU) SET(CMAKE_FIND_ROOT_PATH "../propgcc") SET(CMAKE_OBJECT_COPIER "../propgcc/bin/propeller-elf-objcopy") SET(CMAKE_SPIN_COMPILIER "../propgcc/bin/bstc") ELSEIF(WIN32) CMAKE_FORCE_C_COMPILER("../propgcc/bin/propeller-elf-gcc.exe" GNU) CMAKE_FORCE_CXX_COMPILER("../propgcc/bin/propeller-elf-g++.exe" GNU) SET(CMAKE_FIND_ROOT_PATH "../propgcc") SET(CMAKE_OBJECT_COPIER "../propgcc/bin/propeller-elf-objcopy.exe") SET(CMAKE_SPIN_COMPILIER "../propgcc/bin/bstc.exe") ENDIF() SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) ################################################################################ # @file # @par MIT License - TERMS OF USE: # @n Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # @n # @n The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # @n # @n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. ################################################################################Project Builder
################################################################################ # @file # CMake Lists Project File # # @version @n 1.0 # @date @n 9/1/2012 # # @authors @n Kwabena W. Agyeman # @copyright @n (c) 2012 Kwabena W. Agyeman # @n All rights reserved - Please see the end of the file for the terms of use # # @par Update History: # @n v0.1 - Original release - 9/1/2012 ################################################################################ SET(PROJECT_NAME "pong.elf") SET(SOURCE_FILES "pong.c") SET_SOURCE_FILES_PROPERTIES("pong.c" PROPERTIES COMPILE_FLAGS "-mcog -Os") ADD_EXECUTABLE(${PROJECT_NAME} ${SOURCE_FILES}) SET_TARGET_PROPERTIES(${PROJECT_NAME} PROPERTIES LINK_FLAGS "-mcog -Os") ################################################################################ # @file # @par MIT License - TERMS OF USE: # @n Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # @n # @n The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # @n # @n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. ################################################################################Directory Linker
################################################################################ # @file # CMake Lists Directory Linker # # @version @n 1.0 # @date @n 9/1/2012 # # @authors @n Kwabena W. Agyeman # @copyright @n (c) 2012 Kwabena W. Agyeman # @n All rights reserved - Please see the end of the file for the terms of use # # @par Update History: # @n v0.1 - Original release - 9/1/2012 ################################################################################ # http://nctusdk.blogspot.com/2011/10/add-all-subdirectories-in-cmake.html FILE(GLOB subdirs RELATIVE ${CMAKE_CURRENT_SOURCE_DIR} "*/CMakeLists.txt") FOREACH(dir ${subdirs}) IF(${dir} MATCHES "^[^/]+//CMakeLists.txt$") STRING(REGEX REPLACE "^([^/]+)//CMakeLists.txt$" "\\1" subdir ${dir}) ADD_SUBDIRECTORY(${subdir}) ENDIF() ENDFOREACH() ################################################################################ # @file # @par MIT License - TERMS OF USE: # @n Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # @n # @n The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # @n # @n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. ################################################################################Library Source File - YOU EDIT THIS
################################################################################ # @file # CMake Lists Library Source Code File # # @version @n 1.0 # @date @n 9/2/2012 # # @authors @n Kwabena W. Agyeman # @copyright @n (c) 2012 Kwabena W. Agyeman # @n All rights reserved - Please see the end of the file for the terms of use # # @par Update History: # @n v0.1 - Original release - 9/2/2012 ################################################################################ SET(C_SOURCE_CODE digitalRead.c digitalWrite.c pinMode.c ) # Put your C source code file names above. SET(CXX_SOURCE_CODE ) # Put your CXX source code file names above. SET(COGC_SOURCE_CODE ) # Put your COGC source code file names above. SET(PASM_SOURCE_CODE ) # Put your PASM source code file names above. SET(C_SOURCE_FLAGS "-Os" ) # Put your C compilier flags above - use quotes here. SET(CXX_SOURCE_FLAGS "" ) # Put your CXX compilier flags above - use quotes here. SET(COGC_SOURCE_FLAGS ) # Put your COGC compilier flags above. SET(PASM_SOURCE_FLAGS ) # Put your PASM compilier flags above. ################################################################################ # @file # @par MIT License - TERMS OF USE: # @n Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # @n # @n The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # @n # @n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. ################################################################################Library Builder File - READ ONLY
################################################################################ # @file # CMake Lists Automatic Library Builder File # # @version @n 1.0 # @date @n 9/2/2012 # # @authors @n Kwabena W. Agyeman # @copyright @n (c) 2012 Kwabena W. Agyeman # @n All rights reserved - Please see the end of the file for the terms of use # # @par Update History: # @n v0.1 - Original release - 9/2/2012 ################################################################################ # DO NOT EDIT THIS FILE - PLEASE EDIT THE "source-list.cmake" FILE! INCLUDE(source-list.cmake) STRING(REGEX REPLACE "^.*/(.+)$" "\\1" LIBRARY_NAME ${CMAKE_CURRENT_LIST_DIR}) IF(DEFINED C_SOURCE_CODE AND DEFINED C_SOURCE_FLAGS) SET_SOURCE_FILES_PROPERTIES(${C_SOURCE_CODE} PROPERTIES COMPILE_FLAGS ${C_SOURCE_FLAGS}) ENDIF() IF(DEFINED CXX_SOURCE_CODE AND DEFINED CXX_SOURCE_FLAGS) SET_SOURCE_FILES_PROPERTIES(${CXX_SOURCE_CODE} PROPERTIES COMPILE_FLAGS ${CXX_SOURCE_FLAGS}) ENDIF() IF(DEFINED COGC_SOURCE_CODE) FOREACH(file ${COGC_SOURCE_CODE}) GET_FILENAME_COMPONENT(temp ${file} NAME_WE) LIST(APPEND COGC_OBJECTS ${temp}.cogco) SET_SOURCE_FILES_PROPERTIES(${temp}.cogco PROPERTIES EXTERNAL_OBJECT true GENERATED true) ADD_CUSTOM_COMMAND(OUTPUT ${temp}.cogco COMMAND ${CMAKE_C_COMPILER} ARGS -r -mcog ${COGC_SOURCE_FLAGS} -o ${CMAKE_CURRENT_BINARY_DIR}/${temp}.cog ${CMAKE_CURRENT_SOURCE_DIR}/${file} COMMAND ${CMAKE_OBJECT_COPIER} ARGS --localize-text --rename-section .text=${temp}.cog ${temp}.cogco) ENDFOREACH() ENDIF() IF(DEFINED PASM_SOURCE_CODE) FOREACH(file ${PASM_SOURCE_CODE}) GET_FILENAME_COMPONENT(temp ${file} NAME_WE) LIST(APPEND PASM_OBJECTS ${temp}.pasmo) SET_SOURCE_FILES_PROPERTIES(${temp}.pasmo PROPERTIES EXTERNAL_OBJECT true GENERATED true) ADD_CUSTOM_COMMAND(OUTPUT ${temp}.pasmo COMMAND ${CMAKE_SPIN_COMPILIER} ARGS -c ${PASM_SOURCE_FLAGS} -o ${CMAKE_CURRENT_BINARY_DIR}/${temp} ${CMAKE_CURRENT_SOURCE_DIR}/${file} COMMAND ${CMAKE_OBJECT_COPIER} ARGS -I binary -B propeller -O propeller-elf-gcc ${temp}.dat ${temp}.pasmo) ENDFOREACH() ENDIF() IF(DEFINED C_SOURCE_CODE OR DEFINED CXX_SOURCE_CODE) ADD_LIBRARY(${LIBRARY_NAME} STATIC ${C_SOURCE_CODE} ${CXX_SOURCE_CODE} ${COGC_OBJECTS} ${PASM_OBJECTS}) ENDIF() ################################################################################ # @file # @par MIT License - TERMS OF USE: # @n Permission is hereby granted, free of charge, to any person obtaining a # copy of this software and associated documentation files (the "Software"), to # deal in the Software without restriction, including without limitation the # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or # sell copies of the Software, and to permit persons to whom the Software is # furnished to do so, subject to the following conditions: # @n # @n The above copyright notice and this permission notice shall be included in # all copies or substantial portions of the Software. # @n # @n THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, # OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE # SOFTWARE. ################################################################################I hope this helps... (I'll see if I can find that backup)
Good luck!