title: CMAKE no rule to make target for internal shared library
body: <p>I wrote a cmake file that builds two shared library a vector3.c and a matrix4.c
  The matrix4 depends on the vector3, if I run my cmake project and only build the vector3 shared library it builds just fine, when I add the matrix4 shared library I get a cmake error. No rule to make target.</p>
  
  <p>The folder structure</p>
  
  <pre><code>core_math
   ------CMakeLists.txt
  -common/
   ------common_structs.h
  -matrix4/
   ------CMakeLists.txt
   ------matrix4/src/matrix4_scalar.c
   ------matrix4/headers/matrix4_scalar.h
  -vector3/
  -------CMakeLists.txt
  -------vector3/src/vector3_scalar.c
  -------vector3/headers/vector3_scalar.h
  </code></pre>
  
  <p><strong>core_math/CMakeLists.txt</strong></p>
  
  <pre><code>PROJECT(core_math)
  CMAKE_MINIMUM_REQUIRED(VERSION 2.8)
  
  ADD_SUBDIRECTORY(vector3_scalar)
  ADD_SUBDIRECTORY(matrix4_scalar)
  SET(CMAKE_ARCHIVE_OUTPUT_DIRECTORY $(CMAKE_BINARY_DIR)/static_lib)
  SET(CMAKE_LIBRARY_OUTPUT_DIRECTORY $(CMAKE_BINARY_DIR)/shared_lib)
  SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY $(CMAKE_BINARY_DIR)/bin)
  
  SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake_modules)
  </code></pre>
  
  <p><strong>core_math/vector3/CMakeLists.txt</strong></p>
  
  <pre><code>PROJECT(vector3_scalar)
  SET(CMAKE_MACOSX_RPATH 1)
  
  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common)
  
  SET(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../common/common_structs.h) 
  SET(SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/vector3_scalar.c ${HEADER_FILES})
  
  ADD_LIBRARY(vector3_scalar SHARED ${SRC_FILES})
  </code></pre>
  
  <p><strong>core_math/matrix4_scalar/CMakeLists.txt</strong></p>
  
  <pre><code>PROJECT(matrix4_scalar)
  SET(CMAKE_MACOSX_RPATH 1)
  
  INCLUDE_DIRECTORIES(${CMAKE_CURRENT_SOURCE_DIR}/../common 
      ${CMAKE_CURRENT_SOURCE_DIR}/../vector3_scalar)
  
  
  SET(HEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/../common/common_structs.h
      ${CMAKE_CURRENT_SOURCE_DIR}/../vector3_scalar/headers/vector3_scalar.h
      ${CMAKE_CURRENT_SOURCE_DIR}/headers/matrix4_scalar.h)
  SET(SRC_FILES ${CMAKE_CURRENT_SOURCE_DIR}/src/matrix4_scalar.c ${HEADER_FILES})
  
  ADD_LIBRARY(matrix4_scalar SHARED ${SRC_FILES})
  
  TARGET_LINK_LIBRARIES(matrix4_scalar vector3_scalar)
  </code></pre>
  
  <p>build error</p>
  
  <pre><code>-- Build files have been written to: /Users/blubee/MATH/project/build
  Scanning dependencies of target vector3_scalar
  [ 25%] Building C object source/core_math/vector3_scalar/CMakeFiles/vector3_scalar.dir/sr
  c/vector3_scalar.c.o
  [ 50%] Linking C shared library $(CMAKE_BINARY_DIR)/lib/libvector3_scalar.dylib
  [ 50%] Built target vector3_scalar
  Scanning dependencies of target matrix4_scalar
  [ 75%] Building C object source/core_math/matrix4_scalar/CMakeFiles/matrix4_scalar.dir/sr
  c/matrix4_scalar.c.o
  make[2]: *** No rule to make target `source/core_math/vector3_scalar//Users/blubee/MATH/pr
  oject/build/lib/libvector3_scalar.dylib', needed by `source/core_math/matrix4_scalar//Use
  rs/blubee/MATH/project/build/lib/libmatrix4_scalar.dylib'.  Stop.
  make[1]: *** [source/core_math/matrix4_scalar/CMakeFiles/matrix4_scalar.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>
  
  <p>if I remove the target_link_libraries from the matrix4_scalar cmakelists.txt file then I get undefined symbols error instead.</p>
  
  <pre><code>Undefined symbols for architecture x86_64:
    "_vec3_deg2rad", referenced from:
        _mat4_rotate in matrix4_scalar.c.o
  ld: symbol(s) not found for architecture x86_64
  clang: error: linker command failed with exit code 1 (use -v to see invocation)
  make[2]: *** [source/core_math/matrix4_scalar//Users/blubee/MATH/project/build/lib/libmatr
  ix4_scalar.dylib] Error 1
  make[1]: *** [source/core_math/matrix4_scalar/CMakeFiles/matrix4_scalar.dir/all] Error 2
  make: *** [all] Error 2
  </code></pre>