[CMake] problem creating a library on mac
Mike Jackson
imikejackson at gmail.com
Thu Sep 27 16:07:32 EDT 2007
Marie,
Use the following in your CMakeLists.txt file, generally near the
top just after you define the PROJECT (... )
SET (LIBRARY_OUTPUT_PATH "${PROJECT_BINARY_DIR}/Bin" CACHE INTERNAL
"For libraries.")
SET (EXECUTABLE_OUTPUT_PATH "${PROJECT_BINARY_DIR}/Bin" CACHE
INTERNAL "For executables.")
This will put all the compiled libraries and executables into the
same bin directory.
Also, I think you may be missing a key philosophy of CMake which is
"Out of Source" builds. In your project folder create a new folder
called "Build". Then from the a terminal run the following commands:
cd Build
cmake ../
make
What this does is create the Build directory, moves into that
directory, then runs cmake from within the Build directory. This will
encapsulate all the cmake files, intermediate files, and compiled
libraries/executables in ONE sub directory within your project. If
you ever need to clean to do a CVS update/Checkout/Distribution or
clean build so can safely remove EVERYTHING within the "Build"
directory and rerun cmake again. Others in the cmake community will
put the build directory at the same level as the ProjectDir. So the
commands look like:
mkdir Build
cmake ../ProjectDir
make
Also, on to the actual problem, can you post the actual linker
command? Run "make VERBOSE=1" and post the output.
--
Mike Jackson Senior Research Engineer
Innovative Management & Technology Services
On Sep 27, 2007, at 3:46 PM, Marie-Christine Vallet wrote:
> Mike Jackson wrote:
>> What are the errors you are getting on OS X?
> I get an undefined symbol error for several of my variables.
> If I do the linking manually, leaving out the library, and putting
> the .o of the library and use the same flags, it works.
>>
>> Also, at least one comment, I am not sure you want to be setting
>> the PROJECT_BINARY_DIR Variable?
>>
>> What are you trying to do with this statement:
>>
>> SET(PROJECT_BINARY_DIR
>> ${CMAKE_SOURCE_DIR}/bin)
>>
> I just wanted the binary to be in this folder (and all the files
> created by cmake to be in this directory so I could clean up my
> directory more easily )
> _______________________________________________
> CMake mailing list
> CMake at cmake.org
> http://www.cmake.org/mailman/listinfo/cmake
More information about the CMake
mailing list